A visitor opens your website and gets "502 Bad Gateway" instead of your homepage, your shop or your booking form. Often the page is almost blank, with one line of text and sometimes the name of a server program under it. The visitor did nothing wrong, and reloading does not always help. Until the cause is gone, everyone who arrives sees the same error and leaves.
The short answer: a 502 Bad Gateway error means a server in between, such as a proxy, a load balancer or a content delivery network (CDN), asked the server that builds your pages for an answer and got no valid answer back. If you only want the short definition, read what 502 Bad Gateway means. This guide is about getting your website back: the usual causes for a small business site, a checklist you can work through in order, and when to call your host.
What a 502 Bad Gateway error means for your website
Many websites do not answer visitors from one single server. A front server receives the request first and passes it on to the server or program that builds the page. The front server can be a web server like nginx, a load balancer at your host, or a CDN or security service that sits in front of your site. When the server behind it crashes, is overloaded or cannot be reached, the front server has nothing to send. It answers with a 502.
You may see it written in different ways, depending on the server and the browser:
- 502 Bad Gateway, often with "nginx" or another server name below it
- HTTP Error 502 or Error 502
- 502 Proxy Error
- "The proxy server received an invalid response from an upstream server"
- "Bad Gateway" on an empty page
All of these mean the same thing: the problem is between the servers that run your website, not on the visitor's phone or computer. Many 502 errors last only a minute or two. When it stays, something on the server side needs fixing.
502, 500, 503 or 504: which error do you have?
These server errors look alike, but each one points to a different part of the chain:
- 500 Internal Server Error: the server that builds the page ran into a problem it could not handle, often a bug, a broken plugin or a wrong setting. See how to fix a 500 internal server error.
- 502 Bad Gateway: a server in between got no valid answer from the server behind it, for example because that server crashed, restarted or could not be reached.
- 503 Service Unavailable: the server is up but cannot handle requests right now, usually because of maintenance or too many visitors. Read what 503 Service Unavailable means.
- 504 Gateway Timeout: the server in between did get through, but waited too long for an answer. Read what 504 Gateway Timeout means.
A 4xx error is different again: then the request itself is the problem, such as a missing page or a page that needs a login. See what a 404 error is and how to fix a 401 Unauthorized error.
The usual causes of a 502 error on a small business site
The program that builds your pages crashed or restarted
On many hosting packages, the web server hands each page request to a separate program, for example PHP for most content management systems. If that program crashes, hangs or is being restarted, the web server in front gets no answer and shows a 502. A plugin or script that uses far too much memory can make it crash again and again.
Too many visitors or too little server capacity
A newsletter, an ad, a mention on social media or a wave of bots can bring many visitors at once. A small hosting plan then runs out of memory or processing power, the program behind the web server stops answering, and visitors get 502 errors until it is quiet again. Errors that come and go at busy moments point to this cause.
A CDN, firewall or security service cannot reach your server
If a CDN or security service sits in front of your website, it is the one that shows the 502 when it cannot reach your own server. That happens when your server is down, when the service still points to an old server address, or when a firewall on your server blocks the service's requests because it sees them as an attack.
A move to new hosting or a DNS change
After a move to another host, or a change in the DNS records of your domain, part of the internet still sends visitors to the old address for a while. If the old server is already switched off, or the proxy still points to it, those visitors get errors. DNS changes can take up to 24 to 48 hours to spread.
A recent change to the site
A new plugin, a theme or software update, a change in a server setting or a new piece of custom code can make the program behind the web server fail. If the error started right after a change, that change is your first suspect.
An outage or maintenance at your hosting provider
Sometimes nothing on your side changed at all. Hosting companies and CDNs have outages and maintenance too. Their status page usually tells you within minutes.
How to fix a 502 Bad Gateway error, step by step
Work through these checks in order. The first ones take a minute and need no access to anything; the later ones need your hosting account or your host's help.
- Wait a minute and reload the page. A server that restarts or a short peak in visitors causes many 502 errors that pass by themselves. If the page works again, keep an eye on it.
- Open it in a private window and on your phone over mobile data. If it works there, the problem is close to you: clear your browser cache, switch off a VPN and try again. If it fails everywhere, the problem is on the server side.
- Check how much of the site is affected. Open the homepage, a few other pages and the parts that matter most: the contact form, the shop, the booking page. One page that fails points to the code behind that page. The whole site failing points to the server, the hosting or a CDN.
- Look at your host's status page, and your CDN's if you use one. If they report an outage or maintenance, there is nothing to fix on your side: wait for it to end and check again.
- Undo the last change. Think of a plugin you installed, an update, a new server setting or a piece of code. Undo it or restore the backup from just before, then test again.
- Check your domain's DNS records after a move. If you changed hosting or DNS recently, make sure the records point to the new server only. Remove old records that still point to the old one, then give the change time to spread.
- Test without the CDN or security service in front. Most of these services let you pause them for a moment. If the site works without it, the problem is in the connection between that service and your server, often a firewall on your server that blocks it.
- Check your server's limits and restart what you can. Your hosting panel shows how much memory and processing power your site uses. If it sits at the limit, stop the heavy job that is running, block bad bot traffic or move to a larger plan. Some panels also have a button to restart the PHP service or the site.
When to call your host
Contact your hosting provider when the error stays longer than a few minutes, when it keeps coming back, or when the checks above need access you do not have. Hosts can see the server logs and limits that you cannot, and they can restart the programs behind your website. Send them:
- The exact addresses that show the error, and the ones that still work.
- When it started, with the time zone, and whether it is constant or comes and goes.
- The exact message, ideally with a screenshot, including the server name under it.
- Whether you use a CDN or security service in front of the site.
- What changed just before: updates, plugins, code, settings, a move or a DNS change.
- What you already tried, and what happened after each step.
What a 502 error does to your Google results
A 502 that lasts a few minutes does little harm. When search engines keep finding 5xx errors, they visit your site less often, and pages that keep failing can drop out of the results until they work again. Fix the cause first, then check your pages in Google Search Console. Our guide on crawl errors explains how, and how to handle website downtime covers what to do when the whole site is offline. Website monitoring tells you when your site returns errors, before your customers do.
How WEMASY keeps 502 errors off your website
On a WEMASY website, the hosting and the publishing are part of the platform. There is no server, PHP service or web server setting for you to restart or set up, and the servers are managed for you.
- Your own domain is checked for you. When you connect a domain you own elsewhere, WEMASY shows exactly which DNS records to add, and which old ones to remove, such as AAAA records. The DNS Status shows Pending, Unverified or Verified, and you can click Recheck DNS. See connecting an existing domain.
- A change that broke something can be undone. Every change you, the AI chat or a connected tool makes is saved in your site's history. On the Versions page you can go back to what was live before and publish again. See make a version live and roll back.
- Help when it stays. If your WEMASY website shows a server error for more than a few minutes, send our support team a ticket with the address and the time. See support tickets.
Frequently asked questions
What does 502 Bad Gateway mean in plain words?
A server in between, such as a proxy, a load balancer or a CDN, asked the server that builds your page for an answer and got no valid answer back. The problem is between the servers that run the website, not on the visitor's device.
Is a 502 error my fault or my host's?
It can be either. A plugin, a change on your site or a DNS change after a move can cause it. An overloaded server, a crashed PHP service or an outage at your host or CDN causes it too. If nothing changed on your side, check your host's status page first.
How long does a 502 error last?
Many last only a minute or two, while a server restarts or a peak in visitors passes. If it stays longer than a few minutes, or keeps coming back, something on the server side needs fixing.
What is the difference between a 502 and a 504 error?
With a 502 the server in between got no valid answer from the server behind it. With a 504 it did get through, but waited too long for an answer.
Can a visitor fix a 502 error?
Rarely. Reloading after a minute, a private window or switching off a VPN can help when the problem is close to the visitor. In most cases the fix is on the website's side.
Does a 502 error hurt my Google ranking?
A short error does little harm. If search engines keep finding 502 errors, they visit your site less often and can drop the failing pages from the results until they work again.