How to Fix a 502 Bad Gateway Error in WordPress

Apr 23, 2018 | Errors and Troubleshooting

502 bad gateway error can be shown due to many reasons. Our website is connected to many servers like a reverse proxy server, upstream server, application server, database server and web server. Before we know how to fix a 502 bad gateway error, let take a look why this error occurs.
When the reverse proxy server receives an invalid response from any other server it shows 502 gateway error.
There are few reasons due to which 502 bad gateway response occurs.
  1. Bug in PHP scripts
  2. Server is overloaded
  3. Problem with the router
  4. Browser cache is aggressive
  5. DNS ( Domain name system ) issue
  6. Main server down. Either the server is down or has no connectivity.
  7. Requests blocked by the firewall. The firewall blocks the connectivity between the main server and other servers.

After reading this article, if you still couldn’t fix the problem, please feel free to contact our WordPress malware removal service.

Variation of 502 Error

502 bad gateway error appears in many variations because of different web servers, web browsers, and operating systems.
  • Error 502
  • HTTP 502
  • 502 Proxy Error
  • 502 Bad Gateway
  • A blank white screen
  • 502 Bad Gateway NGINX
  • HTTP Error 502 – Bad Gateway
  • 502 Service Temporarily Overloaded
  • Windows Update fails due to 502 error displays WU_E_PT_HTTP_STATUS_BAD_GATEWAY
  • 502 Server Error: The server encountered a temporary error and could not complete your request.”
  • That’s an error. The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. That’s all we know.”
  • In Twitter 502 gateway error is shown as ” Twitter is over capacity “.

How to Fix a 502 Bad Gateway Error

502 bad gateway error is the issue with the server and it can also be a user side error. Here are some ways on how to fix a 502 bad gateway error

Need a Website Fix

If you want to secure your WordPress website at cheap rates, click the button below.

Try to Reload Your Website

The first approach is to wait for few minutes and refresh your web page.
You can perform hard refresh using Ctrl + F5 to reload your website as it bypasses the cache and checks if the problem is fixed or not.
You can try the different browser to see if the error disappears or not.

Clear Browser Cache

It is a good idea to clear your browser cache, autofill form data, passwords, download history, and cookies, if you see 502 Service Temporarily Overloaded.
You should clear all the browsing data from the beginning of the time.
After that just close your browser and restart your computer.

Restart Your Router

The most common troubleshooting method is to restart your internet router.
Home networks have gateways through which they connect, the issue with the router can show you 502 bad gateway.
All you have to do is just unplug your router and wait for 60 seconds and then plug it back.
Wait for 2 minutes after turning it on and then check whether the error is fixed or not.

Disable Your CDN Temporarily

The best example of a CDN (Content Delivery Network ) is Cloudflare but their free service plan causes the 502 Bad Gateway NGINX. Simply disable the CDN temporarily and check if the site is working properly.
There are two type of 502 gateway error in CDN, one is caused due to host and for the other one, you should contact the support if you see this 502 Bad Gateway NGINX error.

Check DNS Problems

DNS ( Domain name system ) resolve around IP address. If it does not connect to correct IP address, you see  502 bad gateway error.
As you migrate your server to the new host which involves changing the DNS name, the change takes place anytime within 36 hours which could show the 502 bad gateway error.
You should clear your local DNS cache to solve bad gateway error. Consider changing DNS to your router or computer to solve this issue.

Update and Fix Your WordPress Themes & Plugins

WordPress themes and plugins should be updated regularly because outdated themes and plugins may cause problems which distract the server and you end up seeing the 502 Error.
All you can do is deactivate all the plugins through FTP to fix the error. If the error renames the plugins, change it back. Now reactivate all the plugins to find the faulty one and remove it.
If the plugin is not the problem maybe bug is in the theme. Log in to the root directory of the WordPress website via FTP and download a copy of your active theme to your computer. Now delete the active theme and refresh the website.
If the website shows white screen then the problem is a theme. All you can do is change it to default theme while fixing the active theme.

Check Your Host Server

Check your host server whether it is responsive or not. This could be occurred due to any of the stream server if they are unreachable.
Check your server is online or not by using ping test or traceroute.
If your server shows offline or not connected properly, you should contact your host service providers.

Need a Website Fix

If you want to secure your WordPress website at cheap rates, click the button below.