WordPress 502 Bad Gateway Error (Meaning & How To Fix It?) Best of 2023

WordPress 502 Bad Gateway Error (Meaning & How To Fix It?)

In WordPress, there are many types of error occurs which create confusions and sometimes frustration as well. Error is very helpful in order to determine what is going wrong on our website. If we talk about error the most popular one is 502 bad gateway error.

It is the most popular error because it occurs regularly around the entire web. Here in this blog, we will try to explain What is 502 bad gateway error, its cause and how to fix it?

You always try to visit your website without facing any errors. But some errors like 502 bad gateway error, Page not found 404 error, 500 internal server down stops you to reach your website.

502 bad gateway error occurs not only to WordPress sites, this error is also occurs even in popular services such as Gmail, Twitter, and Cloudflare. So to fix this problem, initially we need to understand the reason for the occurrence of 502 bad gateway error and on the basis of reason try to fix the issue.

WordPress 502 Bad Gateway Error: What it Means?

502 bad gateway error
WordPress 502 Bad Gateway Error

Basically, a 502 bad gateway error occurs when your WordPress hosting server gets an invalid response for the requested page. But if we talk about bad gateway error there are many types of 500 status error codes (501,502,503,504 ) and all of them have a slightly different meaning.

There are many free web hosting available in the sector you are working on. But almost each of the free websites hosts has some sort of catch out on all the WordPress hosting.

The error basically occurs when you visit a website your browser sends a request to a web server. The web server processes the request received from the browser and then sends back the requested resource along with an HTTP header. HTTP status code is not visible unless something goes wrong.

Web server is a software which receives your request for accessing a web page. It runs only a couple of security checks on your HTTP request and takes you to the web page.

Variations of 502 bad gateway error

Due to various web servers, browsers and operating system there are variations in 502 bad gateway error but there is no difference between them. If we talk about variations of 502 bad gateway error, it is of many types i.e:

  • 502 bad gateway
  • HTTP Error 502- bad gateway
  • Error 502
  • 502 Proxy Error
  • 502 Server Error
  • A blank white screen
  • 502 service Temporarily Overloaded
  • Temporary error 502
  • HTTP 502
  • 502. That’s is an error
  • Bad gateway: The proxy server received an invalid response from server.

Some of other variations of 502 server error

502 server error
WordPress 502 Bad Gateway Error – Server Error

In this 502 bad gateway error web server received an invalid response while acting as a proxy server. Basically this is your problem with the page you wants to open and it cannot be displayed. In this type of error when the web server contacted the upstream content server then it won’t get any response from the upstream content server.

502 web server
WordPress 502 Bad Gateway Error – Invalid Response

If we talk about Twitter might shows a different message for a 502 bad gateway error, such as twitter is over capacity and Google display 502. That is an error. The server encountered a temporary error and could not complete your request.

502 error

502 error has a negative impact on SEO

If we talk about 502 errors, basically used for WordPress maintenance mode and allows Google to check back at a later time. If we don’t fix the 502 error then 502 error can have a negative impact on SEO because if the site is not working for an extended period of time, say more than 6 hours then Google might see the 502 error as a site level issue that needs to be addressed. This could impact your site rankings.

Here SEO is known as Search Engine Optimization, where search engine is a service which allows all internet user to search for any content, query, and product throughout the world wide web. The search engine optimization of a website needs different tools and strategies. As most of the site is created by using WordPress.

Nowadays web application including a WordPress website is hosted on multiple servers. A couple of servers are enlisted below:

  • A web server that serves your website files.
  • A database server that runs your WordPress databases.
  • The website server that runs the login, PHP code and any other content your WordPress site depends on.
  • A gateway server (also known as a reversed proxy server) running software such as Nginx (read as Engine-X),
  • Apache and Varnish among others.

When you visit your WordPress website through any browser. It generates multiple requests for all the parts which combine and create the page you see in a browser.

These requests are transferred to the gateway server which finds out where to send the request. Then, the gateway server retrieves:

  • MySQL databases from the database server.
  • PHP and the other content from the application server.
  • Images, JavaScript, CSS, themes, plugins and other files from the web server.

As, CSS stands for Cascading Style Sheet. These are the documents which contain the styling rules that can be applied to HTML or XML, (along with some structural formats).

Causes of 502 Bad Gateway Error

The most common reason for getting 502 bad gateway error is poor communication between your servers. However, this error can occur due to a number of reasons such as:

  • Browser cache is acting up.
  • Your website server is overloaded.
  • You have the Domain Name System (DNS) issues.
  • Your Content Delivery Network (CDN) is acting up.
  • Problems with your router or networking equipment.
  • The speed of Upstream servers is down or can’t be accessed.
  • The PHP scripts are full of bugs such as faulty WordPress plugins or themes.

Now let’s move on to fix these errors and make your website error free.

How To Fix WordPress 502 Bad Gateway Error

You never get a clear reason of 502 bad gateway error that’s why to remove this we go through every possible cause of an error and try to fix it:

Reload your WordPress Website

Sometimes your server takes time to respond due to a lower speed and heavy traffic. That’s why you encounter the 502 error. So, Before you try any other method wait for few minutes and reload your website. You can use tools to verify whether your site is down for everyone or for you only.

If the website is down for you only, then the problem is in your end. In this case, you can check your website in a different browser. If the website is down for everyone then you need to proceed further to fix the 502 bad gateway error in WordPress.

Clear Browser Cache

You frequently open your WordPress website in your favorite browser and all of sudden the site start showing 502 bad gateway errors. The simple reason for this is cache saved in your browser.

The modern browser saves the files from your website you frequently open in your browser. Next time when you visit your cache website then the browser doesn’t need to request the same files again and again from the server. Unless you updated the page.

A vigorous caching browser can show 502 bad gateway error. And this problem can be solved by simply clear the cache from your browser and again search for a WordPress site.

Restart Your Networking Equipment

If the changing of browser and clearing cache from a browser is not working for you then move on to next method.
Check out whether your networking equipment is working properly or not.

Malfunctioning of Networking equipment can leads to network error 502 bad gateway. Most of the home network have gateway they do especially when your setup involves a router. This can be a source error 502 bad gateway.

To fix this issue Simply, unplug your networking equipment for 60 seconds and plug it again. If you have a router with modem hybrid, plug in the modem first and wait for 60 seconds then plug in the router.

Switch on the equipment and wait for 2 minutes. Now check is it still showing the error or not? Also, restart your device computer or whatever is showing an error.

Disable Your CDN Momentarily

CDN (Content delivery network) is a service that transfers files on behalf of your WordPress website and boosts the performance of your website.

It is a system of distributed servers around the world that are able to provide fast delivery of Internet content according to the geographic locations of the users. Example of CDN is CloudFlare but, its free plan causes 502 bad gateway error.

We can check whether the CDN is the reason for a bad gateway error. Simply disable the service temporarily and check the error is still appear or not.

If the error 502 bad gateway is due to CDN then contact the service provider for support.
DNS (Domain name system) Problems

A central part of the internet provides a way to match a domain name to IP addresses. If your domain does not reach to a right IP address then you encounter with a 502 gateway error. As a matter of fact, when you migrate your domain to a new host this involves the change in DNS name server.

Does the complete migration task take between 12 to 36 hours which could result in a bad gateway error? Best is to allow the domain to migrate completely and successfully.

Other then this we can clear the local DNS cache and change DNS on router & devices to avoid bad gateway 502 error.

Fix Error of Your WordPress Plugins & Themes

Poorly coded plugins and theme instigate the scripts and queries that confuse your server. The server is not able to recognize and it cancel the order. That’s why you receive a bad gateway error 502.

Here, A plugin is defined as a type of software that contains a group of functions that can be added to a WordPress website. They are used to provide additional functionality to your application and theme is a group of stylesheets and templates that are used to describe the appearance and display of a WordPress site.

The poor coding is not always the reason for gateway error. Besides this plugin using third-party services like reCaptcha also cause the error. Sometimes, NGINX rejects the long tokens generated by Google when showing reCaptcha.

By adding reCaptcha you increase a difficulty for random commenters.  The reCaptcha is clear by a human only. So you can easily avoid the comments generated by robotic machines.

How to find out problematic plugin

If you think your plugin is creating the issue you can fix this. Access your WordPress root directory and move to the wp-content ➤plugin, and rename the plugin folder. This will deactivate your plugin for a while.

Reload your site and check the error is disappear or not. If the error is disappeared then rename the file same as the previous name.

Reactivate your plugin and check whether the error appears or not.

Doing this for all plugin will help you to find out the problematic plugin. You can replace the problematic plugin with other plugin or ask for developer support.

How to find out problematic theme

If the plugins are not creating the problem then maybe the theme is creating the issue. To find out whether the theme is the reason for bad gateway error access your WordPress root directory via FTP. Here, FTP stands for File Transfer Protocol. It is a “means of transport” i.e it is used to transfer files from one local computer to a remote website

Move to wp-content ➤theme➤ Your active theme.

Download a copy to your computer as a backup. Now, Click on your active theme and delete it from your WordPress root Directory.

Reload your Site if you saw a white screen instead of an error, then there is the problem. Activate your default theme meanwhile fix the problematic theme.

Update WordPress core, theme & plugin

An outdated version of WordPress, Theme & plugin conducts errors as well as the security risk. Regular updates can fix the errors and save you from disasters of security.

So, Keep you WordPress, theme & plugin updated to avoid such errors.

Check your hosting server

If all the discussed solution is not working for you then it might be an issue with your hosting server. You need to contact your host server Support team and explain the problem you are facing.

Mention all the troubleshooting steps you have taken to fix the issue. All WordPress hosting companies will be able to quickly fix the issue if it is caused by the server.

Check Logs

We can also take advantage of the error log file. Basically, an error log is a record of critical errors that are encountered by the application, operating system or server while executing the code. So with the help of an error log, we can quickly handle the issue.

We can also check the log files in Apache and NGINX which are generally located:

  • Apache:/var/log/apache2/error.log
  • NGINX:/var/log/nginx/error.log

Php timeout issue

Basically, Php timeout occurs if a single PHP process runs more then the max_execution_time or max_input_time set in the PHP configuration on your server.

This basically happens when you’re doing big WordPress Imports and when all of these processes occur then a 502 server error is usually visible and the maximum PHP timeout values available on any platform is based on the current plan.

Check Scripts

Since we create custom themes and functionality in WordPress and sometimes this custom function is also the reason for not handling the HTTP request by the server. Because it generates long tokens which can put stress on the server and because of that 502 bad gateway error occurs.

That’s All!


As you can all of the possible ways to fix a 502 gateway error on your WordPress site. Basically, it is not a client-side based problem but rather than issues with your host. Be aware of third-party plugins and themes with bad code and sometimes the queries which are not optimized are also created a problem.

Hope this beginner guide is help for you. In case of any related problem, use the comment box provided below. Also, share the blogs with your peers.

Still if you are facing any problem, then you can contact to our WordPress support developers by dialling our WordPress help number +1-855-945-3219 (Tollfree).

Leave a Reply