Blog
502 bad gateway: What it means & how web developers can fix these errors

502 bad gateway: What it means & how web developers can fix these errors

Everything you need to know about gateway errors, how to fix them, and how to prevent them from happening.

Blog
Development
502 bad gateway: What it means & how web developers can fix these errors

502 bad gateway: What it means & how web developers can fix these errors

Everything you need to know about gateway errors, how to fix them, and how to prevent them from happening.

No items found.
Written by
Leah Retta
Senior Content Marketing Manager

From time to time, you may open a website to find nothing but a blank white page, perhaps with bold black letters reading “502 bad gateway.”

That error message is even more of a headache when it’s your website that’s failing to load. Luckily, you can start troubleshooting HTTP errors like this as soon as you understand the information they are conveying.

Any time a website fails to load properly, you risk frustrating visitors, losing potential conversions, and negatively impacting your search engine ranking.

But how do you mitigate this? It's simple: by understanding how HTTP status codes work, you'll be able to troubleshoot more quickly and solve 502 bad gateway errors on your site.

What is a 502 bad gateway error?

A 502 bad gateway error is a server-side error indicating that the proxy server you are using to connect to another web server has received an invalid response. This happens when a web server is being used as a gateway to fetch the data you need to load the page from an upstream server.

A 502 bad gateway error is a type of Hypertext Transfer Protocol (HTTP) status code. These HTTP status codes are issued by the server when you make a request, so if you understand what the codes mean, you can decipher errors and troubleshoot more easily. The four HTTP status code types are:

  • 100 Informational - Your request was received by the server, and it is processing further.
  • 200 Success - Your request was completed, and the browser received the expected response from the server.
  • 300 Redirection - Indicates the server needs to take another action, like a 301 redirect, which you can use to reroute a URL to an updated page on your website.
  • 400 Client Error - The request was invalid. This happens when a site or page can’t be reached, like a 404 page not found error.
  • 500 Server Error - Indicates your request was valid, but there is a problem on the server side. This is the category the 502 error falls into, along with the common 500 error that indicates an internal service issue.

A 502 bad gateway error may not always appear the same way every time. There are different versions of the 502 error message, including a blank white screen. Some of the most common include:

  • 502 bad gateway
  • 502 server error
  • Error 502
  • 502 Server Error: The server encountered a temporary error and could not complete your request
  • Bad Gateway: The proxy server received an invalid response from an upstream server
  • HTTP Error 502 – Bad Gateway
  • 502 proxy error
  • 502 Service Temporarily Overloaded
  • HTTP 502
  • Temporary Error (502)

What are the common causes of a 502 bad gateway error

The cause of an error can originate from the user’s equipment, the website’s hosting services, or the CMS used to manage the website.

  • Unresolved DNS - An incorrect or outdated DNS record can result in visitors receiving a 502 error. This may be caused by their DNS server, equipment, browser, or ISP. A DNS error can also happen temporarily if a website has just switched hosting services.
  • Other browser or home equipment issues - There are other issues that can originate from the user’s equipment that can cause or perpetuate a 502 error, like browser extensions.
  • The origin server is down - The server the hosting service is using to store the website data is down. This could be due to overload or other technical issues.
  • A firewall is blocking the request - This happens when a website’s CMS is overzealous in its security services, like DDoS protection systems.

If you know what may be causing an error, you will be able to hunt down the origin and make sure it gets resolved quickly. 

Get our 100 video course on web design — for free

From the fundamentals to advanced topics — learn how to build sites in Webflow and become the designer you always wanted to be.

Start the course
Get our 100 video course on web design — for free

From the fundamentals to advanced topics — learn how to build sites in Webflow and become the designer you always wanted to be.

Start the course
Start the course

What to do if you see a 502 bad gateway page when browsing

If you are browsing the internet and receive a 502 bad gateway page, you can try a few techniques to fix it on your end. 

First, try checking to see if the website is down generally or just for you. Check a website like downforeveryoneorjustme.com and the business’s social media for other folks receiving the same error. Or see if a friend can access the site from their browser.

If you can’t find any indications the website is down, try some of the following strategies:

  • Refresh the page. The first and easiest step — this often does the trick.
  • Try accessing the site on another browser. For example, if you’re on Chrome, try Firefox.
  • Check the website on your other devices. For example, if you’re on mobile, check on your laptop.
  • Restart your browser or computer. Reload the page after restarting your browser or computer.
  • Clear your cache or delete your cookies. Sometimes, the site is back up but your browser cache version is still giving you an error.
  • Use your browser in “safe modewithout extensions or add-ons. Some extensions can “break” websites.
  • Restart your router and modem. Your home equipment can be the origin of unresolved DNS errors.
  • Wait and try again later. Sometimes, you just have to wait out a server error. Most are resolved quickly, and you’ll have luck trying again in a few minutes.
  • Reach out to the website owner. If you’ve been trying to access a site for a while with no luck, you can use social media or email to contact the website owner and inquire about it.

How to prevent and fix a 502 bad gateway error on your website

If it’s your own website that has started serving 502 bad gateway errors, you’ll want to fix it as soon as possible to avoid disappointing your users and negatively impacting your SEO. A temporary server error that is resolved within a few minutes won’t hurt your search ranking. However, frequent extended periods of server errors will become detrimental

Note: you may not always be able to fix a 502 error since it is often caused on the hosting or user side, but there are some ways you can prevent, fix, or mitigate the impact of 502 errors.

1. Contact your web hosting provider

First, reach out to your web hosting provider to look closely at the problem and provide more information. They will have greater visibility into the servers hosting your site and may be able to pinpoint the problem.

Check your plugins, themes, and firewall

If your CMS uses a lot of plugins or themes those add-ons can cause problems that result in a 502 error. Check each plugin or theme that you are using on your site. You can also temporarily disable your firewall or plugins in your CMS to see if the problem is there.

In general, you want to choose plugins that are updated frequently and instead, opt for a CMS that relies less on plugins for functionality.

Make sure users can contact you

Your visitors may be the first to notice that your site is down or showing 502 bad gateway errors. They can alert you so you can quickly resolve the problem. Make sure they have an easy way of contacting you in addition to your website. This could be social media, a publicly available email address, or a Google Business Profile.

Customize your error page

You can create customized error pages for your website fairly easily. While it doesn’t solve the problem, users will feel like they are still reaching your website and it’s simply unavailable rather than just getting a blank page. A custom page can make your site look more professional and help ensure visitors come back and try again.

The Twitter Fail Whale is a popular example of a 502 bad gateway error page, and it helped keep users engaged while Twitter dealt with the technical problems. You can follow this custom 404-page tutorial and create an error page that’s designed to match the rest of your site. Consider building a creative 404 page for an easy moment of delight for your users, or you can even create your own illustration or purchase a design like these 502 bad gateway illustrations from Dribbble.

Choose reliable hosting and support to prevent errors from the start

An ounce of prevention is worth a pound of cure. Prevent 502 errors and other HTTP problems on your site by making sure it is set up securely from the beginning. Choose a reliable CMS and web hosting service, and the security practices, technical SEO, and redirects you set up will all help you avoid negatively impacting your user’s experience with error codes.

Select your web hosting carefully. Your hosting service will play the biggest role in how fast and reliable your website is. Read reviews and look for hosting services that are tailored to the volume of traffic and content quantity on your website. You want to look at speed, reliability, scalability, security, and customer support. With high-quality hosting, your visitors will be able to reliably access your site whenever they want to.

Last Updated
September 6, 2023
Category