Nginx Error: nginx: [error] CreateFile() “D:\nginx-1.20.1/logs/nginx.pid” failed (2: The system cannot find the file specified)

background

After modifying the Nginx configuration file Nginx.conf, you want to restart Nginx to make the configuration take effect. CMD enter Nginx installation directory and enter the command:   Nginx -s reload

Error: nginx: [error] createfile() “D: \ nginx-1.20.1/logs/nginx. PID” failed (2: the system cannot find the file specified)

Cause analysis

The direct cause of the problem is that there is no Nginx.pid file in the logs directory under the Nginx installation directory. Generally, the Nginx.pid file will be automatically created when Nginx starts

To start or restart Nginx, you need to kill the original Nginx process. You need to find the original process according to Nginx.PID, where PID is actually the original process ID

The reason for this may be that Nginx is not started or Nginx.PID is manually deleted. Sometimes, when Nginx is started by double-clicking on the Windows system, the Nginx.PID file cannot be automatically generated in the logs directory

If Nginx is not started (and you are not sure whether it is started), do not use Nginx – s reload command as the start command to avoid this error

 

Solution:

1. Find the original nginx process (if any) in Task Manager and close it, then use the cmd command to start nginx

2. cmd into the nginx installation directory

3. Enter the command start nginx or nginx.exe to start nginx

4. Go to the nginx directory under the logs directory and see if there is a nginx.pid file; if not, repeat the 123 operation

5. If nginx.pid has been generated, you can restart normally after modifying the configuration file

6.nginx -s reload

Similar Posts: