Error 502 Bad Gateway: How to fix it in WordPress?

Whether you’re the website owner or a visitor, getting a 502 bad gateway error can be frustrating. Instead of the page you wanted to see, you get a blank page with a 502 error message on it.

Updated: June 6, 2022
Error 502 Bad Gateway: How to fix it in WordPress?

Need content for your business? Find top writers on WriterAccess!

For business owners, that’s the last thing they want to see. They can’t afford for potential clients to leave their website and go to the competition. However, it is possible in many cases to fix a 502 gateway error.

In this blog post, we will explain what a 502 Bad Gateway Error is, the possible causes, and how to fix it.

    What is a 502 Bad Gateway Error?

    What is a 502 Bad Gateway Error?

    When you visit a website, your browser will send a request to the server of the website. The server replies to the browser with a 3-digit HTTP status code that lets the browser know if the request has been completed successfully. A 502 error is one of the HTTP status codes.

    There are various 500 error codes and all of them mean that there is an error on the server-side. In the case of the 502 error, what is happening is that the proxy server is getting either no response at all or an invalid response from an upstream server.

    Without some digging, it’s hard to know any more than that. Many sites only display the 502 bad gateway error, which doesn’t give further information on what specifically went wrong.

    In many cases, however, this error is a temporary one that will resolve on its own.

    When you get this error, different sites and browsers might display it in different ways.

    Here are just some of the messages you might get:

    • 502. That’s an error
    • 502
    • Error 502
    • HTTP 502
    • 502 Proxy Error

    All of these alternative messages mean the same thing.

    What Causes a 502 Bad Gateway Error?

    There isn’t just one cause for a 502 error. That’s why it can be difficult to resolve. This can cause problems for business owners. Instead of being able to show off their top-quality, informative, and targeted content, their visitor instead gets the dreaded blank page and an error code.

    In some cases, the server is overloaded, either by too many visitors at once, or possibly by a DDOS attack. The server has no more memory available to display the web page and instead returns the 502 error.

    Occasionally, the server actually times out when it takes longer than expected to return the browser request.

    If a server is down, it will be unable to return a request to the browser and you’ll get the 502 error.

    Firewalls can also cause an issue. A visitor’s firewall may block your site just to them alone, or your firewall may be too reactive and block requests from legitimate visitors.

    If you have changed your DNS recently, you may find that your DNS isn’t fully propagated yet, and your site will display the error.

    You may also have a DNS error where the DNS doesn’t resolve to the right IP address or indeed to any IP address. Other network errors may include ISP issues or routing problems.

    Sometimes there may be no server issue at all, but for some reason, there is a problem on the visitor’s end. They may have a problem with their router or internet connection. Their firewall may be causing a problem, or there could be a browser issue.

    How Can You Fix a 502 Bad Gateway as a Website Owner?

    As a website owner, it’s vital to keep on top of your website uptime and be aware of any errors. You can’t afford to miss out on quality traffic because there is a 502 bad gateway error.

    If you do get one of these errors, there are steps you can take to solve it. If you aren’t technical yourself, then call in your web developer and let them get to work.

    However, before you start any website edits or tweaks, back up your site in full, just in case something goes wrong. Even better if you can copy your site and run tests on a non-live version. That way, if anything breaks, you haven’t caused errors on your actual site.

    It’s also worth checking if your hosting is down before you start needlessly exploring error logs and coding.

    Error 522 (‘Connection Timed Out’): How to Fix this Error

    1) Test Your Plugins

    With WordPress, it’s sometimes the case that a new plugin or a plugin update can cause an error. Temporarily disable or uninstall each new plugin, one at once.

    If you disable them all at once, you may fix the error, but you’ll have no way of knowing which one caused it.

    2) Rollback Updates

    WordPress will often issue a beta version of the latest update before the final version comes out. If you’ve been trialing the beta version, this may be where your problem lies. Or it may be that the newest update doesn’t suit your site for some reason.

    Try rolling back your WordPress version and see if that fixes the error.

    3) Check Your File Permissions

    If you’ve done any updates or added plugins, your file permissions may have been altered. Go through your permissions and make sure they are as they should be.

    4) Go Through Your Web Server Logs

    You should be able to access your server logs and see the latest activity on your site, including any errors. This may guide you toward a possible solution.

    5) Ping Your Site

    Use a ping test to check if your server is responding. If it’s not, then it’s time to reach out to your web host and ask them to check your server and resolve the problem.

    6) Disable Your Content Delivery Network

    If you’re using a CDN, such as Cloudflare, this may be causing the problem. Disable your CDN temporarily and see if the problem is resolved. If it does, then contact your CDN company for help.

    7) Have You Recently Changed Your DNS?

    If you’ve moved web hosts or bought a new domain, you will need to change your nameservers to the ones your web host uses or your site won’t work. When you do this, it can take up to 48 hours for the changes to propagate across the internet.

    This will give a temporary 502 error which will be resolved when the changes are fully propagated.

    8) Debug Your Code

    If you have custom code on your website, faulty code could be the reason for your 502 error. You will need to go through your code line by line to spot any errors and debug it.

    9) Check Your Firewall Configuration

    Firewalls are vital to protect your site from hackers and bad actors, but they can be overreactive. Check your configuration and ensure your firewall isn’t rejecting perfectly good traffic for no reason.

    What is Error 403 and how to fix it?

    How Can You Fix a 502 Bad Gateway as a Website Visitor?

    As you can see above, there’s often nothing you can do as a website visitor when you encounter a 502 error code.

    However, sometimes, the error is either temporary or on your end.

    Before you click away from the website, try a quick refresh of your browser. A temporary error may well have vanished by the time the page refreshes.

    If not, use a site like isitdownrightnow.com to check whether the site isn’t working for everyone or whether it’s just not working for you.

    If the site is down completely, then you’ll have to revisit it later in the day. If it’s down just for you, then here’s what you can do:

    1) Try a Different Browser

    You may find that Chrome displays an error but that Opera and Internet Explorer work just fine. Before you start tweaking settings and rebooting things, this is a potential quick fix that might get you to your page.

    2) Clear Your Cache and Cookies

    If you have an outdated or corrupted version of the site in your cache, then this may be what’s causing the 502 error. Clear out your cache and cookies and you could find the site works perfectly again.

    3) Check Your Browser Extensions

    Many of us use browser extensions, such as Mozilla Color Picker or the Pin button from Pinterest. Occasionally, a browser extension might be what’s causing the issue.

    Disable your browser extensions and try the website. Then re-enable them one at once to find the culprit.

    4) Turn it Off and Turn It On Again

    We had to say it, didn’t we? Sometimes the obvious solution is to reboot your computer or your router and see if it makes a difference.

    5) Check Your ISP

    If all else fails, it’s worth contacting your ISP to see if they have a problem. They may have blocked the site for some reason.

    How to create a custom error 404 page

    Other HTTP Status Codes Similar to 502 Bad Gateway

    There are many different HTTP status codes, including the famous 404 error for page not found, or 301 redirects to point people to a page that has moved.

    The 500 status codes are entirely server codes, giving you information on if a server is responding and why not. 504, for example, is a gateway timeout error and 500 is an internal server error.

    Mozilla has compiled a complete list of all HTTP status codes. It’s worth keeping that list to hand if you rely on your website for attracting and selling to customers.

    Wrap Up: Keep Your 502 Errors Under Control and Keep Your Visitors Happy

    As a business, it’s important to make sure your site has optimum uptime. Keeping a close eye on your error codes and your website logs and you’ll ensure your site visitors get a great experience when they browse your site.

    In addition to optimal uptime, you also need great content. Take a look at our article on website content creation and check your content maturity.

    Share
    facebook
    linkedin
    twitter
    mail

    Human Crafted Content

    Find top content freelancers on WriterAccess.

    Human Crafted Content

    Find top content freelancers on WriterAccess.

    Subscribe to our blog

    Sign up to receive Rock Content blog posts

    Rock Content WriterAccess - Start a Free Trial

    Order badass content with WriterAccess. Just as we do.

    Find +15,000 skilled freelance writers, editors, content strategists, translators, designers and more for hire.

    Want to receive more brilliant content like this for free?

    Sign up to receive our content by email and be a member of the Rock Content Community!

    Talk to an expert and enhance your company’s marketing results.

    Rock Content offers solutions for producing high-quality content, increasing organic traffic, building interactive experiences, and improving conversions that will transform the outcomes of your company or agency. Let’s talk.