Top 7 Ways to Fix 502 Bad Gateway Error

By Last Updated: January 25, 2024
bad gateway 502

You, as a user, have different experiences while accessing websites on your device. Sometimes accessing a website is difficult for you. There are different error messages on your device screen at different times. A 502 bad gateway is one of common errors you could come across. This issue is very common with WordPress websites and popular web services like Cloudflare, Gmail, and Twitter. 

What is a 502 Bad Gateway Error?    

A 502 Bad Gateway error is a communication error that occurs between two servers. It occurs when the server which a user is connecting to receives an invalid response from the upstream/inbound server. This server communication error happens due to several reasons, such as DNS issues, server overload, unresolved domain names, network connectivity problems, or website configuration issues. A website administrator, a hosting service provider, or a user can sort out the issue.     

502 Bad Gateway Variations 

You can notice this server communication error with several other names with the same meaning. Here are some common 502 Bad Gateway variations for your kind information:

  • 502 Bad Gateway
  • 502 Proxy Error
  • Error 502
  • 502 Service Temporarily Overloaded
  • A blank white screen
  • HTTP Error 502 – Bad Gateway
  • 502 Server Error: The server encountered a temporary error and could not complete your request
  • HTTP 502
  • Temporary Error (502)
  • 502 bad gateway Cloudflare
  • 502. That’s an error
  • Bad Gateway: The proxy server received an invalid response from an upstream server 

Steps to Fix 502 Bad Gateway Error

Refresh or Reload the Website/Web page  

Step 1: Wait for 2-3 minutes after noticing a 502 error on your device screen.

Step 2: Go to the left top corner. 

Step 3: Touch the Reload option, which is near the back or forward arrow mark. Or, press the CTRL and F5 keys together or simply press the F5 key. 

Step 4: To know whether a website is offline, use an online tool like Host Tracker or Website Planet. 

Clear the Browser Cookies and Cache 

Clear Cookies

Step 1: Go to the three-dot menu on the top right corner of your web browser, such as Microsoft Edge. 

Step 2: Scroll down the options and click on History. 

Step 3: Check the box against each listing and choose a time range (prefer All) under Clear Browsing Data. 

Step 4: Now, click on the Clear Now option.   

Step 5: For Google Chrome, three-dot menu > History > History > Clear Browsing Data > Check Box against each item and Choose a time range (prefer All time) > Clear Data.  

Step 6: Follow your onscreen instructions for other web browsers like Firefox and Safari. 

Go into the Incognito Mode or InPrivate Window

incognito mode new tab

Step 1: Go to the three-dot menu. 

Step 2: Scroll down the options and choose Incognito Mode in Google Chrome, InPrivate Window in Microsoft Edge, or New Private Window in Firefox. Otherwise, simply press the Ctrl, Shift, and N keys together.  

Step 3: Type the URL of that website and hit the Enter button.  

Check on Another Device 

Step 1: Take another device and open a web browser on it. Opt for a smartphone if you are currently using a Windows PC. 

Step 2: Request your family members or a friend to access that website on their device. If the website is opening on another device, there is an issue with your PC. 

Sort out DNS Server Problems

command flush DNS

Step 1: Open the Command Prompt on your Windows PC. 

Step 2: Type the command – ipconfig /flushdnsin the command window and hit the Enter button to flush DNS servers. 

Step 3: For your Mac desktop/laptop, type the command – dscacheutil -flushcache – in the terminal to flush DNS servers. 

Try a Different Web Browser

Step 1: Open another web browser. Opt for Google Chrome or Firefox if you are using Microsoft Edge as your web browser. 

Step 2: Type the URL of the website in the address bar and hit the Enter key.   

Check with Your Host if You are Website Admin

As an administrator of the website, you can talk to the representative of your web hosting service provider and request them to solve the issue if it is at their end. 

Except for the last one, all above steps can help users sort out the bad gateway or related issues. As a user, you can deactivate Firewall and disable Antivirus software temporarily, restart your internet device in this regard. If you are web admin, you can check your themes & plugins, examine logs, restart your PHP, and do allied web development jobs to resolve the issue.    

Note – I have done copy paste for 502 bad gateway variations and the commands in the command prompt.