Nginx Server Errors
Nginx 500 Internal Server Error
Internal Server Error — Nginx failed while processing the request or communicating with an upstream
What 500 Means
The 500 error on the Nginx Server Errors indicates internal server error — nginx failed while processing the request or communicating with an upstream. This typically occurs due to php-fpm or fastcgi process crashed or is not running.
When Nginx itself encounters an internal error rather than forwarding a 500 from an upstream, it is often due to a module or scripting layer failure. Check the Nginx error log first, then the application log.
Technical Background
Nginx returns its own 500 when an internal processing step fails, distinct from forwarding a 500 received from an upstream backend. Common internal failure points include FastCGI modules, embedded scripting, and SSL certificate processing.
The Nginx error log at /var/log/nginx/error.log with debug level enabled contains the specific failure point for any 500 returned by Nginx.
Common Causes
- PHP-FPM or FastCGI process crashed or is not running
- Syntax error in a Lua or Perl module embedded in the Nginx configuration
- Upstream application returning an invalid response that Nginx cannot forward
Typical Scenarios
- PHP-FPM pool exhausted all workers, causing Nginx to return 500 on new requests
- Nginx Lua script raising an unhandled exception
- Misconfigured proxy_pass or fastcgi_pass pointing to a non-existent socket
What to Know
An Nginx 500 indicates a failure within Nginx's own processing layer, independent of upstream application behavior. The error log distinguishes Nginx-internal failures — such as module errors or FastCGI socket failures — from forwarded upstream errors.
Frequently Asked Questions
Common questions about Nginx 500 error
Check the Nginx error log. If the error originates in Nginx itself (e.g., a Lua error or FastCGI failure), it appears there. If the upstream app returned 500, Nginx logs a 'upstream sent invalid header' or similar message.