When it comes to WordPress, there are a lot of different errors that can be downright frustrating and confusing. A few that come to mind are the white screen of expiry or the frightening fault establishing a database connection. But an even more popular one is the 502 bad gateway error. Why? Because this regularly happens around the unabridged web, not only to WordPress sites, but fifty-fifty popular services such as Gmail, Twitter, and Cloudflare. But of grade, we actually merely care about how information technology impacts your WordPress site. Read more below about what causes this mistake and some solutions on how to apace resolve information technology.

  • 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 error specifically means that the server received an invalid response from an inbound server.

The Internet Technology Task Strength (IETF) defines the 502 Bad Gateway error as:

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

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

There are many different types of 500 status error codes (500, 501, 502, 503, 504, 508, 520, etc.) which all take slightly different meanings. These signal that the request was accepted, just 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 error can nowadays itself in a number of different means. Just they all have the aforementioned pregnant. Below are merely a couple of the many different variations you might see on the web:

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

Another variation yous might see is a "502 server error."

502 server error in Chrome
502 server error in Chrome

And here is nonetheless another variation. "502 – Web server received an invalid response while acting equally a gateway or proxy server. There is a problem with the folio yous are looking for, and it cannot exist displayed. When the Web server (while interim 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- spider web server received an invalid response

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

Twitter is over capacity
Twitter is over chapters (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 complete your asking. Please try again in 30 seconds. That's all we know."

Google 502 error
Google 502 error

502 Errors Touch on on SEO

Dissimilar 503 errors, which are used for WordPress maintenance mode and tell Google to check back at a later time, a 502 error can have a negative impact on SEO if not fixed right away. If your site is only downward for say 10 minutes and it'south beingness crawled consistently a lot of times the crawler will merely get the page delivered from enshroud. Or Google might non even take a take chances to re-clamber it before it's dorsum upward. In this scenario, you're completely fine.

However, if the site is down for an extended period of time, say 6+ hours, then Google might come across the 502 error as a site level issue that needs to exist addressed. This could impact your rankings. If you're worried about repeat 502 errors you should effigy out why they are happening to begin with. Some of the solutions below can help.

How to Gear up the 502 Bad Gateway Error

A 502 bad gateway error is typically a problem with the network/server, however, information technology can also be a client-side consequence. And then we'll dive into a little of both. Check out these common causes and means to fix the 502 bad gateway error to and get support and running.

ane. Endeavour Reloading the Page

Ane of the easiest and commencement things yous should endeavour when encountering a 502 bad gateway error is to merely look a infinitesimal or so andreload the page (F5 or Ctrl + F5). It could exist that the host or server is but overloaded and the site volition come right back. While you lot're waiting, you could besides quickly effort a different browser to rule that out as an outcome.

Another matter you tin do is to paste the website into downforeveryoneorjustme.com. This website will tell you if the site is downwards or if it's a problem on your side.

downforeveryoneorjustme
downforeveryoneorjustme

ii. Clear Your Browser Cache

Whenever you encounter issues like these it can be good to clear your browser cache. Beneath are instructions on how to do it in the various browsers:

Subscribe Now

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

3. DNS Issue

A 502 gateway error could also be considering of a DNS result, such as the domain is not resolving to the right IP, or the DNS server is not responding. If you have just migrated your WordPress site to a new host, is it important to wait for things to fully propagate, which can accept upwardly to 24 hours in some cases. This depends upon the TTL value of your DNS records.

You can too try flushing your local DNS cache. This is similar to clearing your browser enshroud.

In Windows simply open upwards 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 can enter the following in the terminal:

dscacheutil -flushcache

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

And lastly, yous could temporarily change your DNS servers. By default, DNS servers are automatically assigned past your ISP. Merely you could try temporarily changing these to a public DNS server, such equally Googles. In fact, some adopt to use Google's public DNS long-term. If you have a premium DNS propagation ordinarily is a lot faster.

4. Bank check With Your Host

The principal reason we typically run into a 502 bad gateway error is due to an event with the web host. Sometimes aquery, script, or request will take also long and so information technology is canceled or killed past the server. A lot of hosts, specially shared hosts implement what they telephone call a "kill script." Basically what this does is information technology will end a request after a certain period of fourth dimension so that it doesn't take a site downwardly or impact other users. If you do a Twitter search for "bad gateway" y'all can see thousands of tweets happening every 24-hour interval alerting their hosting visitor of the trouble.

502 bad gateway tweets
502 bad gateway tweets

1 reason y'all 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% private and is not shared, even between your own sites. This greatly reduces the chance of seeing a 502 bad gateway error. We aren't running aggressive kill scripts like some shared hosts are. And fifty-fifty if one of your sites does happen to get down, information technology won't impact your other sites.

Another reason you could see a 502 gateway error with your host is also due to the fact that the server is simply not reachable, either because information technology is downwardly or there is no connectivity. In this case, it is recommended to check your WordPress host's condition page or open a support ticket.

v. Temporarily Disable CDN or Firewall

It could also be an issue with your content delivery network (CDN) or firewall. If you are using a 3rd-party CDN provider an easy mode to troubleshoot this is to simply disable your CDN temporarily. For example, we are large fans of the free CDN enabler plugin. If yous are using that, you can simply deactivate the plugin and and then test your site. Wp-admin not working? Simply log in to your site via SFTP and rename the plugin's binder to cdn-enabler_old. This volition temporarily disable the CDN connection. The same goes for WP Rocket or any other plugin you might accept hooked up to your CDN.

Rename plugin folder temporarily
Rename plugin folder temporarily

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

However, before yous go blaming Cloudflare, information technology is important to know that there are ii unlike types of 502 bad gateway errors variations with Cloudflare equally seen below:

502 Bad Gateway at Cloudflare (Variation 1)

If you see the following screen, this is actually a problem on Cloudflare's end, in which instance you should reach out to them for support. You lot can also cheque Cloudflare's condition page to meet if they're currently experiencing an outage.

502 bad gateway error
502 bad gateway error

502 Bad Gateway at Cloudflare (Variation ii)

If you come across 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 mistake and GoDaddy'due south firewall. The consequence 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. Check Your Plugins and Themes

A lot of times the reason for scripts and queries being canceled by the server is due tobad code on your WordPress site, perchance from a 3rd party plugin or theme. Nosotros have likewise seen a lot of misconfigured caching plugins generate 502 errors. A few ways yous can troubleshoot this is by deactivating all your plugins. Remember, you won't lose whatsoever data if you simply deactivate a plugin.

If you tin can nevertheless access your admin, a quick style to do this is to browse to "Plugins" and select "Conciliate" from the majority deportment card. This will disable all of your plugins. If this fixes the issue you'll need to discover the culprit. Start activating them ane by one, reloading the site after each activation. When you see the 502 gateway error return, you've constitute the misbehaving plugin. You tin then reach out to the plugin programmer for help or postal service a support ticket in the WordPress repository.

Deactivate all plugins
Conciliate all plugins

If yous tin can't admission your admin you tin FTP into your server and rename your plugins folder to something like plugins_old. So check your site again. If it works, then you volition need to test each plugin one past i. Rename your plugin folder back to "plugins" and so rename each plugin folder inside of if it, one by one, until you find it.

Rename plugin folder
Rename plugin binder

Ever makes sure your plugins, themes, and WordPress core are up to date. And bank check to ensure you are running a supported version of PHP. You can always achieve out to your host for assistance. We utilize New Relic and other troubleshooting methods hither at Kinsta to assistance clients narrow down what plugin, query, or script might be causing the error. You can also use your own custom New Relic key.

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

If it turns out to exist an efficient query or bad code in a plugin, y'all might demand to bring in a WordPress programmer to fix the issue.

7. Check Logs

You should also take reward of your fault logs. If you lot are a Kinsta client, you can hands see errors in the log viewer in the MyKinsta dashboard. This can help you lot quickly narrow down the upshot, especially if it'south resulting from a plugin on your site.

Check error logs for 502 bad gateway errors
Check fault logs for 502 bad gateway errors

If your host doesn't accept a logging tool, yous tin can besides add the following lawmaking to your wp-config.php file to enable logging:

          define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', simulated );        

If you need more than help on how to enable WordPress debugging mode here is a full step past step tutorial.

The logs are typically located in the /wp-content directory. Others, similar hither at Kinsta might take a defended binder called "logs".

wordpress error logs folder sftp

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

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

If you lot are a Kinsta client you tin can also take advantage of our analytics tool to go a breakdown of the total number of 502 errors and meet how often and when they are occurring. This can aid you troubleshoot if this is an ongoing issue, or mayhap something that has resolved itself.

Response analysis 500 error breakdown
Response analysis 500 mistake breakdown

8. Restart PHP

Finally, you lot can also endeavour restarting PHP. If you're a Kinsta client, you can easily restart PHP from the tools menu within the MyKinsta dashboard. If your host doesn't provide this, you can ever open up up a support ticket and ask them restart PHP.

Restart PHP
Restart PHP

9. PHP Timeout Event

PHP timeouts occur if a unmarried PHP process runs for longer than the max_execution_time or max_input_time ready in the PHP configuration on your server.  This is a common occurrence if y'all're doing big WordPress imports. When this happens a 502 server fault is normally displayed. If yous run into a PHP timeout these values may demand to exist elevated.

Yous tin bank check with your current WordPress host about what values are gear up on your server and if they can be increased. On the Kinsta platform, these values are gear up to 300 seconds (5 minutes) by default. The maximum PHP timeout values bachelor on our platform are based on your current hosting plan.

Summary

As y'all can meet there are quite a few things you can do to troubleshoot and prepare a 502 gateway error on your WordPress site. Typically this is not on the client-side, only rather an issue with your host. Third-party plugins and themes with bad code or unoptimized queries are as well things to picket out for. Was at that place anything we missed? Perhaps yous take another tip on troubleshooting 502 gateway errors. If then, permit us know below in the comments.


Salve time, costs and maximize site performance with:

  • Instant aid from WordPress hosting experts, 24/vii.
  • Cloudflare Enterprise integration.
  • Global audience reach with 29 data centers worldwide.
  • Optimization with our built-in Awarding Performance Monitoring.

All of that and much more than, in i plan with no long-term contracts, assisted migrations, and a 30-solar day-money-back-guarantee. Bank check out our plans or talk to sales to observe the plan that'south right for you lot.