The 502 error code, known as Bad Gateway, means that a server acting as a go between received a broken or invalid answer from the server it was asking. Large websites rarely work from one machine. Your request first reaches a front server, then passes to the one that builds the page. If the second one crashes, restarts or replies with nonsense, the front server shows a 502.
For a visitor this is almost always a wait and retry situation. You may see "502 Bad Gateway", "HTTP Error 502", "Bad gateway: the proxy server received an invalid response" or a plain error page from the web server software. Below you will find what to check on your side and what the site owner must do.
Common causes
1The main server crashed or restarted
How to tellError comes and goes, and the site recovers after a few minutes
What fixes itWait and reload; owner restarts the app service if it stays down
2The app behind the front server is overloaded
How to tellAppears at busy hours along with slow pages
What fixes itTry later; owner adds capacity or caching
3Front server points to the wrong place
How to tellAppears right after a hosting move or settings change
What fixes itOwner corrects the upstream address in the proxy settings
4Firewall blocks traffic between servers
How to tellConstant 502 after a security change, not a short glitch
What fixes itOwner allows the connection between the two servers
5Stale DNS or a cached bad page on your side
How to tellOthers open the site, you still see 502
What fixes itClear browser cache, flush DNS or switch to mobile data
6Slow or broken script on the site
How to tellOnly a page that runs a heavy task shows 502
What fixes itOwner checks the app log for crashes or timeouts
How to fix it, step by step
Wait two minutes and reload
A restart of the hidden server takes about that long. Press Ctrl + F5 on a computer for a fresh load, or close the tab on a phone and open the link again.
Open the same link on another network
Switch Wi-Fi off and use your SIM data, or have a contact in another town open the page. A 502 for everyone means the site is struggling. A 502 only for you points to your side, so continue with the steps below.
Try a private tab
Use an incognito window to skip saved cache and cookies. If the page loads there, clear the cached data for that website in your normal browser.
Flush DNS on a Windows PC
Open Command Prompt and type
ipconfig /flushdns, then press Enter. After that, close the browser and reopen the site. This clears an outdated address your computer may have stored.Reboot the router or flip airplane mode
A weak home connection can occasionally damage a response in transit. Switch the router off for sixty seconds, or flip airplane mode on a phone. If many sites misbehave, read WiFi not working.
Turn off VPN and extensions briefly
A VPN or a proxy can add its own gateway, and that is another place for a 502 to start. Disconnect it, reload, and compare.
Give it an hour, then write to the site
When an hour goes by and nothing improves, message the support team with the link and the time. Do not repeat payments or form submissions until you confirm the first one failed.
502 error code meaning in simple terms
Think of a shop with a counter assistant and a stock room. You ask the assistant for an item, the assistant calls the stock room, and the stock room shouts back something garbled. The assistant cannot hand you a proper item, so you hear "sorry, bad answer from the back". That assistant is the gateway or proxy. The 502 code is its report. The fault is in the back room, not at your end of the counter.
You open an exam notice page and see 502 Bad Gateway nginx. The word nginx is the front server software. The app behind it was not answering properly. Try again in a few minutes.
How 502 differs from 500, 503 and 504
| Code | Where it fails | Typical wording |
|---|---|---|
| 500 | Inside a single server | Internal Server Error |
| 502 | Reply between two servers is invalid | Bad Gateway |
| 503 | Server busy or paused | Service Unavailable |
| 504 | Reply took too long | Gateway Timeout |
More detail on 500 Internal Server Error, 503 Service Unavailable and 504 Gateway Timeout. See all HTTP status codes too.
How owners fix a bad gateway error code 502
- Check that the app or PHP service is running and restart it. A crashed process is the most common reason.
- Read both logs: the front server's error log and the app log. Messages such as "upstream prematurely closed connection" or "connection refused" show which side failed.
- Verify the upstream address and port in the proxy settings after any move.
- Raise memory and worker limits if the app dies under load.
- Check firewall rules between the front and back servers.
On shared hosting you may not reach these settings. Open a ticket with your host and include the time the error began.
Is the 502 on your end?
Rarely. A 502 page is itself proof that your request travelled all the way to a working front server. If the same site opens on a friend's phone, try the DNS flush and the private tab. If every page on every site fails, the problem is your connection, covered in internet not working.
Frequently asked questions
What does error code 502 mean?
It means a gateway or proxy server received an invalid response from the server it depends on. The page cannot be built until the back server is working again.
How long does a 502 error last?
A restart usually fixes it within minutes. A bad setting or an overloaded server can keep it going for hours until the owner repairs it.
How to fix 502 bad gateway error as a visitor?
Reload after a pause, try a private window, test on mobile data, flush DNS on Windows and turn off VPN. If others also see it, only waiting helps.
Is a 502 error a virus or a hack?
No. It is a communication fault between servers. It does not mean your device is infected or that the site was hacked.
What is HTTP 502 error meaning in Hindi?
It means the site's front server got a galat jawab from the server behind it. In plain words, the website's own setup has a fault and it should be fixed by the site team.