nginx
startup_error
ai_generated
true
nginx: [error] invalid PID number "" in "/run/nginx.pid"
ID: nginx/invalid-pid-number
92%Fix Rate
92%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
PID file is empty, stale, or missing. Usually after unclean shutdown, manual file deletion, or containerized nginx.
genericWorkarounds
-
92% success Kill any existing nginx processes and start fresh
sudo pkill nginx; sleep 1; sudo nginx # or: sudo nginx -s stop 2>/dev/null; sudo nginx
Sources: https://nginx.org/en/docs/http/ngx_http_core_module.html
-
90% success Use systemctl which manages PID tracking automatically
sudo systemctl restart nginx # systemd tracks the PID independently of nginx.pid
-
82% success Verify the PID file path matches nginx.conf
grep pid /etc/nginx/nginx.conf # default: /run/nginx.pid; must match systemd ExecStart expectations
Dead Ends
Common approaches that don't work:
-
Manually write a PID number into the PID file
90% fail
Writing an arbitrary PID causes nginx -s reload/stop to signal the wrong process. Let nginx manage its own PID file.
-
Delete the PID file and hope nginx recreates it
72% fail
nginx only writes the PID file on startup. Deleting it while running makes nginx -s commands fail until next restart.