How to Solve 502 Bad Gateway Issues? - KeyCDN Support (2024)

Updated on April 29, 2022

If you browse the internet long enough, you'll run into a 502 Bad Gateway error code. This is especially true if you frequently visit websites known to be unreliable. While the error can be frustrating, the good news is that it's usually easy to fix.

In this article, we'll take a look at what a 502 Bad Gateway error code is and how you can go about solving it on your own.

What does 502 Bad Gateway mean?

A 502 Bad Gateway indicates that the edge server (server acting as a proxy) could not get a valid or any response from the origin server (also called the upstream server). This can occur for a few reasons, which we'll discuss below. If one of KeyCDN's edge servers receives a 502 Bad Gateway response from your origin server, KeyCDN will return a 500 Origin Not Reachable page.

To better understand how KeyCDN handles certain error codes, check out our CDN Error Codes page.

Usually, a 502 Bad Gateway error code is accompanied by a message letting you know that a "bad gateway" exists. In other words, something went wrong while the server was trying to relay information to another server (usually an upstream server). The most common cause of this issue is an incorrect or outdated DNS record.

What are the reasons for 502 Bad Gateway responses?

Three main culprits cause 502 Bad Gateway responses. These include:

  1. Domain name not resolvable: The domain name is not resolving to the correct IP or it does not resolve to any IP. It is important to note that DNS changes could take same time until they are global fully propagated and active. This is dependent on the TTL, or time to live, defined per record.
  2. Origin server down: The server is not reachable, either because it is down or there is no connectivity to the server given.
  3. Firewall blocks request: A firewall blocks the communication between the edge servers and the origin server. This can also be caused by security plugins of your CMS. Some DDoS protection and mitigation systems might are too overreactive and start blocking requests from our content delivery servers.

How you might see a 502 Bad Gateway error

Based on your web server, you might see a different 502 error.

Every time, it means the same thing. The only different component is their naming conventions. Here are a few examples of what you might see:

  • 502 Bad Gateway
  • HTTP Error 502 - Bad Gateway
  • 502 Service Temporarily Overloaded
  • Error 502
  • 502 Proxy Error
  • HTTP 502
  • 502 Bad Gateway NGINX

You can see in greater detail what the error specifically entails by going to your web server's error log file. All error and diagnostic information is stored in this file making it a valuable resource to check when you need more details about a particular error. You can locate this file in Apache by going to /var/log/apache2/error.log and in Nginx by going to /var/log/nginx/error.log.

You can see what the error specifically entails by going to your web server's error log file in greater detail. All error and diagnostic information are stored in this file, making it a valuable resource to check when you need more details about a particular error. You can locate this file in Apache by going to /var/log/apache2/error.log and in Nginx by going to /var/log/nginx/error.log.

How to solve 502 errors as a web developer

As a web developer or owner of the website, there are a few reasons why you may be experiencing a 502 Bad Gateway error on your origin server. Therefore, you may need to try various methods to resolve the issue. Reference the list of suggestions below:

  • Check if your FQDN (fully qualified domain name) is resolving correctly by using our DNS test tool.
  • Verify if your server is reachable by using a ping test or traceroute.
  • Check your firewall logs if you are seeing unusual drops.
  • If you're a Cloudflare user, try disabling it as once you've reached a certain limit Cloudflare will return a 502 Bad Gateway error to your visitors.

How to solve 502 errors as a visitor

If you're a website visitor and experience a 502 Bad Gateway error then there is also a few things you can try to resolve it. Although the primary issue will almost always be the responsibility of the web developer, visitors can try the following:

  • Perform a hard refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.
  • Clear your browser cache and delete cookies. Your browser may be holding on to certain files that were saved once you visited the website with a 502 error.
  • Restart your computer/networking equipment
  • Change your DNS servers. If you've never changed them in the past you likely still have the default servers assigned to you by your ISP, try using open DNS servers such as Google's Public DNS.

Common solutions for 502 Bad Gateway Error Code

Usually, a 502 error code is the result of a server error. A server error means that the server you are trying to access is unavailable or down. However, it is also possible on the client-side.

Here are some common ways to fix it in detail:

Reload the page

The first and easiest thing you can do is simply reload the page. A 502 error code and a 504 error code are both server-side errors. This means that there is something wrong with the server. The problem could be anything from the server being down to the server being too busy.

A reload will send a new request to the server. The server may be down, but it could also be that the original request timed out. A reload will often fix the problem.

Tools like DownForEveryoneOrJustMe are useful for seeing whether this is a server-side issue or an issue on your end.

Clear your browser's cache

It is also possible that your browser's cache is causing the problem. If you have recently visited the site, your browser may be trying to use an old version of the website. To clear your browser's cache, go to the settings in your browser and look for the option to clear your cache.

In Google Chrome, you can go to the three dots in the top right corner and click More tools. From there, click Clear browsing data.

In Mozilla Firefox, you can go to the three bars in the top right corner and click Options. From there, click Privacy & Security and scroll down to Cookies and Site Data. Click Clear Data.

In Microsoft Edge, you can click the three dots in the top right corner and click Settings. From there, click Choose what to clear under Clear browsing data.

In Safari, you can click the Safari menu and click Preferences. From there, click the Privacy tab and click Manage Website Data. Click Remove All.

Restart your computer and router

It is also possible that the problem is on your end. If you have recently installed new software or made changes to your computer, these could be causing the problem. Try restarting your computer and see if that fixes the problem.

If the problem is on your end, one of your browser's extensions is likely causing the problem. Try disabling all of your browser's extensions and see if that fixes the problem.

If the problem is still not fixed, you can try resetting your router. To do this, unplug your router from the power outlet and wait 30 seconds. After 30 seconds, plug it back in and wait for it to connect to the internet.

Change your DNS servers

If you are still having problems, you can try changing your DNS servers. If you have never changed your DNS servers before, you likely have the default ones assigned to you by your ISP. If your DNS server is not responding or your domain is not resolving the correct IP, it can result in a 502 error.

However, you can try using public DNS servers such as Google's Public DNS.

To change your DNS servers in Windows, go to the Control Panel and click Network and Sharing Center. From there, click Change adapter settings and double-click your internet connection.

Click Properties,then click the Networking tab. From there, double-click Internet Protocol Version 4 (TCP/IPv4).

In the General tab, click Use the following DNS server addresses. Enter 8.8.8.8 for the Preferred DNS server and 8.8.4.4 for the Alternate DNS server.

Click OK to save your changes.

You can also change your DNS servers in your router's settings. The process will vary depending on your router, but you will likely be able to find the DNS settings in the Network or Internet section of the router's settings.

Once you have changed your DNS servers, try loading the website again.

Flush DNS cache

DNS caching can also cause 502 errors. When you visit a website, your computer stores certain information about that site in its DNS cache. This can help your computer load the website faster the next time you visit it. However, if this information is outdated, it can result in a 502 error.

To flush your DNS cache, open the command prompt and enter the following:

Windows: ipconfig /flushdns

Mac: sudo killall -HUP mDNSResponder

Linux: sudo /etc/init.d/networking force-reload

Once you have flushed your DNS cache, try loading the website again.

Temporarily disable Your CDN or firewall

Most servers use a content delivery network (CDN) such as KeyCDN. While very helpful (and important), these services can sometimes cause 502 errors. If you are using a CDN, try temporarily disabling it and see if that fixes the problem.

To disable your CDN in WordPress, go to the CDN tab in the Settings section of your WordPress dashboard and click the Disable CDN button. Click Save Changes.

In other CMSs, the process will be similar. Look for a CDN or Content Delivery Network settings page in your CMS's dashboard and follow the instructions.

Similarly, your firewall could also be the cause of 502 errors. If you are using a firewall, try temporarily disabling it and see if that fixes the problem.

To do so, go to the Control Panel and click System and Security. From there, click Windows Firewall.

Click the Turn Windows Firewall on or off link in the left sidebar. If prompted for an administrator password or confirmation, enter the password or provide confirmation.

Click the Turn off Windows Firewall (not recommended) option for both private and public networks and click OK.

Summary

If you see 502 Bad Gateway errors, there are a few things you can do to try and fix the problem. Usually, this error code is an easy one to fix and requires one of the following:

  • Reload the page
  • Clear your browser's cache
  • Restarting your computer or router
  • Flushing your DNS cache
  • Temporarily disabling your CDN or firewall

If you are still having problems, you can try changing your DNS servers. If you have never changed your DNS servers before, you likely have your ISP's DNS servers configured. However, you can try using public DNS servers such as Google's Public DNS.

Worst case scenario, you will have to contact your ISP's customer support. They should be able to help you troubleshoot the problem and get you back online.

How to Solve 502 Bad Gateway Issues? - KeyCDN Support (2024)

FAQs

How to Solve 502 Bad Gateway Issues? - KeyCDN Support? ›

The error is caused by upstream origin

The custom origin defined in the CloudFront distribution can be a proxy, Content Delivery Network (CDN) hostname, or load balancer connected to the actual origin. If any of these intermediary services fails to connect to the origin, then a 502 error is returned to CloudFront.

How to fix a 502 Bad Gateway error? ›

How Do You Fix The 502 Bad Gateway Error? (9 Possible Solutions)
  1. Refresh The Webpage And Try A Different Browser. ...
  2. Test Using Another Device. ...
  3. Clear Your Browser's Cache. ...
  4. Flush The DNS Cache. ...
  5. Check Your Site's Error Log. ...
  6. Deactivate Your Plugins And Themes. ...
  7. Disable Your CDN Or Firewall. ...
  8. Restart PHP And Increase Your PHP Limits.
Nov 8, 2023

What is error 502 on CDN? ›

The error is caused by upstream origin

The custom origin defined in the CloudFront distribution can be a proxy, Content Delivery Network (CDN) hostname, or load balancer connected to the actual origin. If any of these intermediary services fails to connect to the origin, then a 502 error is returned to CloudFront.

What is error 502 Bad Gateway origin? ›

An HTTP 502 status code (Bad Gateway) indicates that CloudFront wasn't able to serve the requested object because it couldn't connect to the origin server. If you're using Lambda@Edge, the issue might be a Lambda validation error.

What is the status code 502 Bad Gateway? ›

The 502 Bad Gateway error is an HTTP status code that occurs when a server acting as a gateway or proxy receives an invalid or faulty response from another server in the communication chain.

Is 502 Bad Gateway permanent? ›

While the 502 Bad Gateway error is usually indicating a networking error outside of your control, it could be extremely temporary. Trying the page again will often be successful.

How do I fix 502 Bad Gateway on server side? ›

Fixes for a 502 Bad Gateway error
  1. Refresh your browser. (Image: © Future) ...
  2. Clear your browser's cache. (Image: © Future) ...
  3. Temporarily disable your firewall. (Image: © Future) ...
  4. Check with monitoring sites. (Image: © Downdetector) ...
  5. Use a VPN. (Image: © Surfshark) ...
  6. Examine web server logs.
Jul 23, 2024

How do I get around error 502? ›

How to Fix the 502 Bad Gateway Error
  1. Refresh the Page. Usually, a 502 Bad Gateway Error is temporary, stemming from a sudden traffic surge. ...
  2. Check the Site Status. ...
  3. Clear Your Browser Cache. ...
  4. Try in the Incognito Mode. ...
  5. Flush the DNS Cache. ...
  6. Test on Another Device. ...
  7. Check Error Logs. ...
  8. Check Plugins and Themes.
Jun 2, 2024

Is a 502 Bad Gateway my fault? ›

You can receive this error when visiting a website that gets an invalid response from its host server or experiences other issues, such as server overloads, network problems, and configuration issues. The 502 bad gateway error doesn't mean something is wrong with your device or internet connection.

Is 502 Bad Gateway a hack? ›

One of the most frequent reasons that can lead to the 502 bad gateway error is a server overload that cannot handle the numerous requests received. This can be due to either a true overload of users or a DDoS attack, by hackers trying to “DDoSing” the server.

What does 502 Bad Gateway translate to? ›

502 Bad Gateway meaning

A 502 Bad Gateway is an HTTP status code you see when you want to view a web page, but the web server cannot complete the request. The web browser wanted to communicate with the server, but it failed.

What is 502 Bad Gateway registered endpoint? ›

Webserver overload: If a webserver reaches its limit, it can't answer any more requests — the gateway then delivers the status code 502 Bad Gateway. The reason could be an unexpectedly high interest in the site or even a DDoS attack.

What is 502 Bad Gateway Cloud function? ›

Error message BAD_GATEWAY

An error code 502 with BAD_GATEWAY in the message usually indicates that App Engine terminated the application because it ran out of memory. The default App Engine flexible VM only has 1GB of memory, with only 600MB available for the application container.

How do I get rid of bad gateway 502? ›

Check out these common ways to fix the 502 bad gateway error to get back up and running.
  1. Try Reloading the Page.
  2. Check the Site Status.
  3. Try a Different Browser.
  4. Try in Incognito Mode.
  5. Test on Another Device.
  6. Clear Your Browser Cache.
  7. Check for DNS Issues.
  8. Check With Your Host.
Sep 1, 2017

What is error 502 Bad Gateway 404 not found? ›

A 404 Not Found error occurs when content can't be found by the web server. A 502 Bad Gateway error happens when the proxy server can't get any response or gets an invalid response from the upstream server. You come across 404 when requested content was removed or doesn't exist.

What is 502 Bad Gateway ingress service? ›

502 Bad Gateway is an error that can occur at the conatiner, pod, service, or Ingree level, and can also represent a problem with the ingress or the underlying nodes.

How do I get rid of 502 Bad Gateway on Chromebook? ›

-Clear the cookies and browser cache in Chrome. If the above do not help, it may be an extension of Chrome that is causing the issue. If the site works fine in "Incognito Mode", then its likely a Chrome extension that is blocking the usage. To disable an extension, type chrome://extensions in the address bar.

Why does 502 Bad Gateway error occur when trying to turn on wifi calling? ›

In this case, the servers needed to communicate to turn on Wi-Fi calling can't communicate with each other, thus the feature can't be enabled. Unfortunately, 502 errors typically require a fix to be implemented by the web server or proxies in question and can't be fixed by a user.

Top Articles
Hope for free speech? Kat Timpf riffs on the power of comedy and dangers of cancel culture.
Who Is Kat Timpf's Husband? All About Cameron Friscia
Artem The Gambler
Average Jonas Wife
Overton Funeral Home Waterloo Iowa
Noaa Charleston Wv
Goodbye Horses: The Many Lives of Q Lazzarus
How To Be A Reseller: Heather Hooks Is Hooked On Pickin’ - Seeking Connection: Life Is Like A Crossword Puzzle
Horoscopes and Astrology by Yasmin Boland - Yahoo Lifestyle
Localfedex.com
What happens if I deposit a bounced check?
Slay The Spire Red Mask
Tugboat Information
Florida (FL) Powerball - Winning Numbers & Results
Fire Rescue 1 Login
Taylor Swift Seating Chart Nashville
Los Angeles Craigs List
Nissan Rogue Tire Size
Q33 Bus Schedule Pdf
Icommerce Agent
Adam4Adam Discount Codes
Everything you need to know about Costco Travel (and why I love it) - The Points Guy
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Mychart Anmed Health Login
Talk To Me Showtimes Near Marcus Valley Grand Cinema
Greyson Alexander Thorn
Cookie Clicker Advanced Method Unblocked
Timeline of the September 11 Attacks
Access a Shared Resource | Computing for Arts + Sciences
Receptionist Position Near Me
Jailfunds Send Message
Will there be a The Tower season 4? Latest news and speculation
Past Weather by Zip Code - Data Table
Rugged Gentleman Barber Shop Martinsburg Wv
Fairwinds Shred Fest 2023
Dentist That Accept Horizon Nj Health
Royal Caribbean Luggage Tags Pending
Edward Walk In Clinic Plainfield Il
Consume Oakbrook Terrace Menu
Bismarck Mandan Mugshots
Zasilacz Dell G3 15 3579
Blackwolf Run Pro Shop
Nid Lcms
Sun Tracker Pontoon Wiring Diagram
R: Getting Help with R
Woody Folsom Overflow Inventory
Hdmovie2 Sbs
Verizon Forum Gac Family
O'reilly's Eastman Georgia
Thrift Stores In Burlingame Ca
OSF OnCall Urgent Care treats minor illnesses and injuries
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 6224

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.