Nginx 502 Error: Backend Problem

Diagnosing communication between Nginx and PHP-FPM.

The 502 Bad Gateway error with Nginx means the reverse proxy cannot get a valid response from the backend, usually PHP-FPM. It's a communication problem between the two services.

Causes vary: PHP-FPM crash, timeout, misconfigured socket, or exhausted resources. This guide helps you identify the exact source of the problem.

Main Causes

Diagnosis

Solutions

Frequently Asked Questions

How to see if PHP-FPM is overloaded?

Enable pm.status_path in PHP-FPM to see active/idle workers. If all are "active", you're short on workers.

Socket or TCP, which is better?

Unix Socket is faster on the same server. TCP is needed if PHP-FPM is on a different server.

Why does PHP-FPM crash silently?

Often due to memory overflow. Check PHP memory_limit and system memory. Check PHP-FPM logs.

Does MoniTao detect 502 errors?

Yes, MoniTao monitors HTTP code and alerts you immediately on 5xx errors including 502.

Ready to Sleep Soundly?

Start free, no credit card required.