Instructions to fix 502 Bad Gateway error on wordpress

Any errors that make your WordPress website inaccessible will cause you to lose revenue, reduce SEO rankings and greatly lose a large amount of access. One of the most classic errors ever on the internet is the 502 Bad Gateway error on wordpress. It is an annoying error because it is difficult to identify the cause, making troubleshooting difficult.
If you're looking to fix the 502 Bad Gateway error for your WordPress site, keep calm as we provide you with a few tested solutions.
Instructions to fix 502 Bad Gateway error on wordpress
Instructions to fix 502 Bad Gateway error on wordpress

What is 502 Bad Gateway error?

The 502 Bad Gateway error is an HTTP status code error, which means that a server receives an "invalid" response from another server.
Error 502 can and there are many different forms such as:
  • Error 502
  • 502 Bad Gateway NGINX
  • 502 Proxy Error
  • 502 Service Temporarily Overloaded
  • HTTP Error 502 Bad Gateway
  • 502. 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.

What causes 502 Bad Gateway error?

Although 502 bad gateway error usually occurs on the server side, it can also occur due to a problem on the website side. Here are some reasons why you encountered the 502 error:
  • The server may be overloaded due to increased traffic
  • Webserver is not working
  • Wrong configuration of server.
  • Problems with your content distribution network (CDN)
  • Use Nginx Apache proxy and for some reason Apache does not work
  • Browser cache is wrong
  • DNS problem
  • PHP code fails due to a problematic plugin or theme
As you can see in our short list above, 502 error can be caused by many reasons. This means you have to try many different solutions to fix the error.

How to fix 502 Bad Gateway error on wordpress

Here are some measures to fix 502 Bad Gateway error on wordpress.

1. Refresh / Reload your website

As we mentioned, most 502 errors occur on the server side, especially when you use low quality shared hosting. Spike traffic can exhaust your server resources causing you to encounter this nasty error.
Currently provided by HOSTVN WordPress Hosting with Litespeed SSD and web serverver optimized for WordPress source code
Hosting providers often solve problems immediately when their servers encounter problems. So try refreshing your WordPress site a few times to see if the error goes away on its own. Also, try a different browser or device to see if the error fixes itself. Also, to ensure server-side problems, check your site using a tool like
However, if the error persists after trying the fixes above, move on to the next solution in this post.

2. Clear your browser cache

Can't fix 502 error even after refreshing your browser? If so, perform a hard refresh on your browser (CTRL + F5 on Windows computers and CMD + CTRL + R on OS X systems). If that still doesn't work, you can clear your browser cache then try again.
If you are still stuck with the error, the following solution may help.

3. Disable CDN

Do you use CDN as CloudFlare, KeyCDN or another CDN for WordPress? CDNs often route your website traffic to their servers to provide you with better site performance and security.
A problem on their server could cause you to experience port 502. In addition, you may encounter a 502 bad port error if you configured the CDN incorrectly.
To check, pause the CDN and refresh your site. This forces your site to load directly from your host.
If the error persists, you can refer to the following measures.

4. DNS issues

DNS (short for the domain name system) is how domain names (for example, match their corresponding IP addresses. If an error occurs with the DNS settings, you may encounter a 502 error.
In this case, you can also try clearing your local DNS cache. For Windows users, open your command prompt (cmd.exe) and run the following command: ipconfig / flushdns. As a Mac OS X user, please run dscacheutil -flushcache in the terminal.
Try to clear the DNS cache several times and then try to ping your website with CMD (Or Terminal) to make sure your computer is receiving the correct IP of hosting.

5. Check your theme and plugin

If you still haven't solved the 502 error then maybe the problem is with your plugin or theme. You will need to check the plugins and themes to make sure they are working properly.

a. Check for Plugins

Log into the hosting management page and go to the directory containing your source code (usually it is public public_html) using an FTP application like Filezilla or File Manager in cPanel.

Then navigate to the directory wp-content and find the directory plugins. Rename the directory to something like plugin.old to deactivate all your plugins at once. Don't worry, you will not lose any data.

Ctrl + F5 your website to see if the error is gone or not. If you see your site instead of the error, one of your plugins is the problem. Now you will need to check each of the plugins one by one to know exactly what the plugins are causing.

b. Check out the theme

If disabling plugins does not fix anything, you need to check your theme.
Log into your WordPress root directory via FTP or File Manager. Then navigate to wp-content > themes and identify your active topic.
Rename the active themes directory to something like Total.old. This will deactivate active themes and activate WordPress default themes.

Reload your website to check if the error is gone. If the error is still there? That means your theme is fine, in which case you should rename the theme folder back to its original name.
If the error disappears, contact your theme developer for further assistance.

8. If the problem persists, contact your hosting provider

In case after you have tried all of the above measures and still cannot fix it, you need to contact your hosting provider for assistance.


Hopefully, through this article, we will help you fix 502 errors for your website. If you have any contributions, please leave a comment below.
According to wpexplorer
About My name is Nguyen Manh Cuong. I was born in a poor village in Ba Vi district, HA NOI province - windy and sunny land. Currently. Mr Cuong.
Newer Posts Newer Posts Older Posts Older Posts


Post a Comment