Find the cause of a 502 Bad Gateway in the nginx log
nginx 502 bad gateway cause | nginx upstream error log | connect() failed upstream | php-fpm not responding nginx | grep | nginx | 502 | logsgrep -E "upstream|connect\(\) failed" /var/log/nginx/error.log | tail -20Shows the last 20 messages where nginx could not reach the backend (PHP-FPM, Apache or a Node application) or did not get a valid response. Typical messages are connect() failed (111: Connection refused) when the backend is stopped, or upstream prematurely closed connection when PHP processes crashed. The upstream: part of the message reveals which target is meant.
Note: On Plesk, use /var/www/vhosts/system/<domain>/logs/proxy_error_log as the log.
Also searched as
- nginx 502 bad gateway cause
- nginx upstream error log
- connect() failed upstream
- php-fpm not responding nginx