Search code examples
nginxpidsalt-stack

After the first reload: "nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)"


Using Salt I applied states that install and run NGINX (1.14.0-0ubuntu1.7) as a service. Service's status is active but systemctl reload nginx keeps failing thus an updated config cannot be applied.

Full logs:

systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after reload: No such file or directory
systemd[1]: Reloaded A high performance web server and a reverse proxy server.
systemd[1]: Reloading A high performance web server and a reverse proxy server.
nginx[18095]: nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Reload failed for A high performance web server and a reverse proxy server.
systemd[1]: Reloading A high performance web server and a reverse proxy server.
nginx[1209]: nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Reload failed for A high performance web server and a reverse proxy server.

Solution

  • I solved this by restarting nginx instead of reloading:

    service nginx restart
    service nginx status
    

    after this, also a reload worked fine and the pid number is stored in

     /var/run/nginx.pid