When it comes to WordPress, there are a lot of unlike errors that tin can exist downright frustrating and confusing. A few that come up to mind are the white screen of death or the frightening error establishing a database connection. But an even more popular one is the 502 bad gateway fault. Why? Because this regularly happens around the entire web, not just to WordPress sites, merely even popular services such as Gmail, Twitter, and Cloudflare. But of course, we actually only care about how it impacts your WordPress site. Read more than below about what causes this error and some solutions on how to quickly resolve it.

  • What Is a 502 Bad Gateway Error?
  • How to Fix the 502 Bad Gateway Error

What is a 502 Bad Gateway Error?

The 502 Bad Gateway fault specifically means that the server received an invalid response from an inbound server.

The Internet Technology Job Forcefulness (IETF) defines the 502 Bad Gateway error as:

The 502 (Bad Gateway) condition code indicates that the server, while acting as a gateway or proxy, received an invalid response from an entering server it accessed while attempting to fulfill the request.

Every time yous visit a website your browser sends a asking to a web server. The web server receives and processes the request, and so sends back the requested resources along with an HTTP header and HTTP condition lawmaking. Typically an HTTP status code isn't seen unless something goes wrong. It'southward basically the servers manner of notifying you that something has gone incorrect, along with the code on how to diagnose information technology.

There are many unlike types of 500 status fault codes (500, 501, 502, 503, 504, 508, 520, etc.) which all accept slightly different meanings. These indicate that the request was accepted, but the server prevented the fulfillment of the request.

502 bad gateway error in Chrome
502 bad gateway error in Chrome

502 Bad Gateway Error Variations

Due to the various browsers, web servers, and operating systems, a 502 bad gateway mistake tin present itself in a number of different ways. But they all have the same meaning. Below are just a couple of the many different variations you might see on the spider web:

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

Another variation you might run across is a "502 server error."

502 server error in Chrome
502 server error in Chrome

And here is all the same another variation. "502 – Web server received an invalid response while acting equally a gateway or proxy server. In that location is a problem with the page you are looking for, and information technology cannot exist displayed. When the Spider web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server."

502- web server received an invalid response
502- web server received an invalid response

Other services such as Twitter might even show a completely different message for a 502 Bad Gateway error, such as "Twitter is over capacity." This definitely looks a little more user-friendly.

Twitter is over capacity
Twitter is over capacity (Img src: Softpedia)

And here is a snapshot of how Google displays it. "502. That's an error. The server encountered a temporary error and could not consummate your request. Please try over again in 30 seconds. That'southward all we know."

Google 502 error
Google 502 error

502 Errors Impact on SEO

Unlike 503 errors, which are used for WordPress maintenance style and tell Google to cheque back at a afterwards time, a 502 mistake can have a negative touch on SEO if not fixed right away. If your site is only downwards for say 10 minutes and it's beingness crawled consistently a lot of times the crawler will simply get the page delivered from cache. Or Google might non even have a chance to re-crawl it before it's support. In this scenario, you're completely fine.

However, if the site is downward for an extended menses of time, say 6+ hours, and so Google might see the 502 mistake every bit a site level issue that needs to be addressed. This could impact your rankings. If you're worried near repeat 502 errors you should figure out why they are happening to begin with. Some of the solutions below can help.

How to Set the 502 Bad Gateway Mistake

A 502 bad gateway error is typically a problem with the network/server, yet, it can likewise be a client-side issue. So we'll swoop into a trivial of both. Check out these mutual causes and ways to gear up the 502 bad gateway error to and get back up and running.

1. Endeavor Reloading the Page

I of the easiest and offset things you should try when encountering a 502 bad gateway mistake is to merely expect a minute or so andreload the page (F5 or Ctrl + F5). Information technology could be that the host or server is but overloaded and the site volition come up right dorsum. While yous're waiting, y'all could also quickly endeavour a different browser to rule that out as an effect.

Another thing you can practice is to paste the website into downforeveryoneorjustme.com. This website will tell you if the site is down or if it's a trouble on your side.

downforeveryoneorjustme
downforeveryoneorjustme

2. Clear Your Browser Cache

Whenever you see issues like these it can be practiced to clear your browser cache. Below are instructions on how to exercise it in the various browsers:

Subscribe Now

  • How to Force Refresh a Single Page for All Browsers
  • How to Clear Browser Cache for Google Chrome
  • How to Clear Browser Enshroud for Mozilla Firefox
  • How to Articulate Browser Cache for Safari
  • How to Clear Browser Cache for Net Explorer
  • How to Articulate Browser Enshroud for Microsoft Edge
  • How to Clear Browser Cache for Opera

3. DNS Effect

A 502 gateway fault could too exist because of a DNS issue, such as the domain is not resolving to the correct IP, or the DNS server is non responding. If you lot have but migrated your WordPress site to a new host, is it of import to wait for things to fully propagate, which tin can take up to 24 hours in some cases. This depends upon the TTL value of your DNS records.

Y'all can also effort flushing your local DNS cache. This is similar to immigration your browser cache.

In Windows simply open Command Prompt and enter the following:

ipconfig /flushdns
Command prompt - flush DNS
Command prompt – flush DNS

You should see a "Successfully flushed the DNS resolver Cache" if it worked.

For macOS users, you tin can enter the following in the terminal:

dscacheutil -flushcache

Note: In that location is no success message on Macs.

And lastly, you could temporarily alter your DNS servers. By default, DNS servers are automatically assigned by your Internet service provider. But you could endeavor temporarily changing these to a public DNS server, such as Googles. In fact, some adopt to use Google'south public DNS long-term. If you accept a premium DNS propagation unremarkably is a lot faster.

4. Bank check With Your Host

The primary reason we typically run into a 502 bad gateway error is due to an result with the web host. Sometimes aquery, script, or request volition accept too long and so it is canceled or killed by the server. A lot of hosts, especially shared hosts implement what they telephone call a "kill script." Basically what this does is information technology will cease a request after a sure menses of time so that it doesn't have a site downward or impact other users. If you practise a Twitter search for "bad gateway" you can see thousands of tweets happening every day alerting their hosting company of the trouble.

502 bad gateway tweets
502 bad gateway tweets

Ane reason you might want to consider moving to a host like Kinsta is that our platform runs in anisolated software container that contains all of the software resources required to run the site (Linux, NGINX, PHP, MySQL). This means that the software that runseach site is 100% individual and is non shared, fifty-fifty between your own sites. This greatly reduces the chance of seeing a 502 bad gateway error. We aren't running aggressive impale scripts like some shared hosts are. And even if 1 of your sites does happen to go down, it won't impact your other sites.

Another reason you lot could run across a 502 gateway error with your host is as well due to the fact that the server is simply not reachable, either considering information technology is down or in that location is no connectivity. In this case, it is recommended to cheque your WordPress host'south condition page or open up a support ticket.

5. Temporarily Disable CDN or Firewall

It could too exist an issue with your content delivery network (CDN) or firewall. If you are using a 3rd-party CDN provider an easy way to troubleshoot this is to only disable your CDN temporarily. For instance, we are large fans of the free CDN enabler plugin. If you lot are using that, you can simply deactivate the plugin and and so test your site. Wp-admin not working? Simply log in to your site via SFTP and rename the plugin'due south folder to cdn-enabler_old. This will temporarily disable the CDN connection. The same goes for WP Rocket or whatever other plugin you might have hooked up to your CDN.

Rename plugin folder temporarily
Rename plugin folder temporarily

This can also occur sometimes with providers that provide DDoS protection and mitigation or fully proxy services like Cloudflare, as they have extra firewalls in-between. Nosotros have noticed that this happens once in a while on the Cloudflare free plan. Unfortunately, since Cloudflare is a fully proxy service, there is no quick manner to merely disable it.

However, before you go blaming Cloudflare, it is important to know that there are 2 unlike types of 502 bad gateway errors variations with Cloudflare as seen below:

502 Bad Gateway at Cloudflare (Variation 1)

If yous see the post-obit screen, this is really a trouble on Cloudflare's finish, in which case yous should accomplish out to them for back up. You tin can also check Cloudflare's status page to see if they're currently experiencing an outage.

502 bad gateway error
502 bad gateway error

502 Bad Gateway at Cloudflare (Variation ii)

If you lot run into the following screen, this is a problem with your host.

Cloudflare 502 bad gateway at host
Cloudflare 502 bad gateway at host

GoDaddy Firewall

Here is another example with of an HTTP 502 error and GoDaddy's firewall. The issue is actually with the origin server (the hosting provider) due to a timeout, not the firewall itself.

HTTP 502 - GoDaddy Firewall
HTTP 502 – GoDaddy Firewall

6. Cheque Your Plugins and Themes

A lot of times the reason for scripts and queries being canceled by the server is due tobad lawmaking on your WordPress site, possibly from a 3rd political party plugin or theme. We have also seen a lot of misconfigured caching plugins generate 502 errors. A few ways y'all can troubleshoot this is by deactivating all your plugins. Remember, y'all won't lose whatever information if you just deactivate a plugin.

If you lot can still access your admin, a quick way to do this is to browse to "Plugins" and select "Deactivate" from the majority deportment menu. This will disable all of your plugins. If this fixes the issue you'll demand to find the culprit. Start activating them one past one, reloading the site later on each activation. When you see the 502 gateway fault return, y'all've found the misbehaving plugin. Y'all can and so attain out to the plugin developer for assist or post a support ticket in the WordPress repository.

Deactivate all plugins
Deactivate all plugins

If you tin can't access your admin you can FTP into your server and rename your plugins folder to something like plugins_old. And then bank check your site again. If information technology works, then you will need to test each plugin i by ane. Rename your plugin folder dorsum to "plugins" and so rename each plugin binder inside of if it, one by 1, until you observe it.

Rename plugin folder
Rename plugin binder

Always makes sure your plugins, themes, and WordPress core are up to date. And check to ensure you are running a supported version of PHP. You can e'er reach out to your host for assistance. We utilize Kinsta APM and other troubleshooting methods here at Kinsta to aid clients narrow down what plugin, query, or script might exist causing the error. Y'all can also use your ain custom New Relic central if you have your own license.

Time consuming queries to database
Time-consuming queries to the database

If it turns out to be an efficient query or bad code in a plugin, you might need to bring in a WordPress developer to gear up the issue.

7. Check Logs

You should also take advantage of your error logs. If you are a Kinsta client, you can easily see errors in the log viewer in the MyKinsta dashboard. This can help you apace narrow downward the issue, especially if it's resulting from a plugin on your site.

Check error logs for 502 bad gateway errors
Bank check error logs for 502 bad gateway errors

If your host doesn't have a logging tool, you can likewise add together the post-obit code to your wp-config.php file to enable logging:

          ascertain( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); ascertain( 'WP_DEBUG_DISPLAY', imitation );        

If you lot need more help on how to enable WordPress debugging fashion hither is a full stride by step tutorial.

The logs are typically located in the /wp-content directory. Others, like here at Kinsta might have a dedicated folder chosen "logs".

wordpress error logs folder sftp

You lot can also bank check the log files in Apache and NGINX, which are commonly located here:

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

If you are a Kinsta client y'all can also take advantage of our analytics tool to become a breakdown of the full number of 502 errors and run across how often and when they are occurring. This can assistance you troubleshoot if this is an ongoing issue, or perhaps something that has resolved itself.

Response analysis 500 error breakdown
Response analysis 500 mistake breakdown

8. Restart PHP

Finally, yous can also try restarting PHP. If you're a Kinsta client, you can easily restart PHP from the tools carte within the MyKinsta dashboard. If your host doesn't provide this, you can e'er open a support ticket and inquire them restart PHP.

Restart PHP
Restart PHP

9. PHP Timeout Effect

PHP timeouts occur if a single PHP process runs for longer than the max_execution_time or max_input_time prepare in the PHP configuration on your server.  This is a common occurrence if you're doing big WordPress imports. When this happens a 502 server error is usually displayed. If you see a PHP timeout these values may demand to exist elevated.

Y'all can check with your current WordPress host most what values are assault your server and if they tin can exist increased. On the Kinsta platform, these values are set to 300 seconds (5 minutes) by default. The maximum PHP timeout values available on our platform are based on your electric current hosting program.

Summary

Equally y'all can meet in that location are quite a few things you can do to troubleshoot and gear up a 502 gateway error on your WordPress site. Typically this is not on the client-side, but rather an issue with your host. Third-party plugins and themes with bad code or unoptimized queries are also things to watch out for. Was at that place anything we missed? Possibly you have another tip on troubleshooting 502 gateway errors. If so, permit u.s. know below in the comments.


Save time, costs and maximize site performance with:

  • Instant assist from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience reach with 29 data centers worldwide.
  • Optimization with our congenital-in Application Operation Monitoring.

All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-mean solar day-money-dorsum-guarantee. Check out our plans or talk to sales to notice the plan that's correct for you.