Fill the Server: 80% off your first 4 monthly invoices, monthly billing. Ends Nov 30, 2026. 25 spots in this batch.FILL25
Fill the Server, annual: about 29.63% off your first annual invoice. Ends Nov 30, 2026.FILL25Y
Fill the Server, 2 year term: about 15.69% off your first biennial invoice. Ends Nov 30, 2026.FILL25B
Fill the Server, 3 year term: about 11.11% off your first triennial invoice. Ends Nov 30, 2026.FILL25T
80% off your first 3 months, monthly billing. Ends Dec 25, 2027.3MONTHS80
50% off your first annual Shared term. Ends Dec 31, 2027.50SHARED
Shared Starter, 3 year term: C$105.84 total.MOOSE294
20% off your first 3 monthly VPS invoices. Ends Dec 31, 2027.20VPS3
25% off your first annual base VPS term.25VPS

← All guides

Troubleshooting

Nginx bad gateway: how to troubleshoot a 502

Published August 2026 · 8 min read

Nginx can be healthy enough to answer the browser while the application behind it is stopped or unreachable. A 502 therefore points toward the connection between the proxy and its upstream more often than toward DNS or the visitor’s browser.

Read both Nginx and upstream logs at the same time

Nginx may report connection refused, timeout, invalid response, or socket permission errors. The application, PHP-FPM, Node process, or other upstream can explain why it was unavailable at that exact moment.

Verify the configured upstream destination

Check the hostname, IP, port, Unix socket path, protocol, and whether the service is listening where Nginx expects it. A deployment can move an application to a new port while leaving the proxy config unchanged.

Check process health and resource failures

An upstream can crash because of memory pressure, a full disk, bad configuration, dependency failure, or application exception. Restarting it may restore traffic, but collect evidence before the restart when possible.

Tune timeouts only when the request should legitimately take longer

Increasing proxy timeouts is not a universal 502 fix. If the upstream is slow because of a bad database query or overloaded worker pool, a longer timeout can make users wait longer without removing the cause.

Next step

An Nginx 502 Bad Gateway usually means the proxy could not get a usable response from its upstream. Check process health, sockets, ports, timeouts, permissions, and upstream logs.

Get hosting troubleshooting help

Keep reading

Related guides.

HTTP 500, 502 and 503 errors explained for website owners

Learn what HTTP 500, 502 and 503 errors usually indicate, which layer to investigate, what evidence to collect, and when restarting a service is not the real fix.

Read the guide

cPanel error logs: where to look when a site breaks

cPanel exposes recent website errors, while server and application logs may contain deeper detail. Learn which log to check for PHP, Apache, cPanel, mail, and system failures.

Read the guide

Database connection failed: how to check the whole path

A database connection failure can involve DNS, host, port, firewall, service state, TLS, credentials, privileges, connection limits, or application configuration.

Read the guide

More troubleshooting guides

We will handle the move. You check it first.

Your current site stays online until your new one is ready. You approve the copy first, and if anything is not right we switch you back right away. The price you pick is the price you renew at.

Start my free moveSee plans and prices
See pricesFree move