Home › Knowledgebase › KB-1209

502 bad gateway error: how to fix your website

Summary

This guide helps you troubleshoot and resolve: 502 bad gateway error: how to fix your website. Follow the steps below to fix the issue.

Quick Tip: Need immediate assistance? 💻 Open a Ticket

Common Causes

A 502 Bad Gateway error occurs when a web server acting as a gateway or proxy receives an invalid response from an upstream server. In simpler terms, the server you are trying to reach is acting as a middleman, but it cannot get a valid response from the server actually hosting your website. This usually indicates a problem with the origin server or the network path between servers, rather than an issue with your local computer or internet connection.

Remember — If you host with us, you don't need to do this yourself — just Open a Ticket and our Brisbane team will get it sorted.

Quick Fix Steps

  1. Refresh your browser page by pressing F5 or Ctrl + R on Windows, or Cmd + R on macOS.
  2. Wait a few minutes and try accessing the website again. The upstream server may be temporarily overloaded or restarting.
  3. Clear your browser cache and cookies, then attempt to load the site again.
  4. Try accessing the website from a different device or network to rule out local connectivity issues.

Detailed Instructions

Check Your DNS Settings

If your domain's DNS records are pointing to the wrong IP address, the gateway server may be unable to reach your origin server.

  1. Log in to your domain registrar or DNS management control panel.
  2. Locate the DNS Management or Zone Editor section.
  3. Verify that your A record or CNAME record points to the correct IP address provided by your hosting provider.
  4. Save any changes and allow time for DNS propagation, which can take up to 24 to 48 hours.

DNS changes are not instant. If you recently updated your nameservers or IP address, the 502 error may resolve automatically once propagation completes.

Review Firewall and Security Settings

A firewall or security plugin may be blocking legitimate requests from your gateway server to your origin server.

  1. Log in to your hosting control panel or server dashboard.
  2. Open the Firewall or Security section.
  3. Check for blocked IP addresses and ensure your gateway or proxy server IP is not blacklisted.
  4. If you use a web application firewall (WAF) or CDN, temporarily disable it to see if the error clears.

Be cautious when changing firewall rules. Disabling security features can leave your website vulnerable to attacks.

Investigate Server Performance and Resources

A 502 error can occur when your origin server is overwhelmed and cannot respond in time. This is common on shared or underpowered hosting environments where resource caps are reached.

  1. Log in to your hosting control panel.
  2. Navigate to the Resource Usage, Server Metrics, or Statistics section.
  3. Check for spikes in CPU, memory, or concurrent connection usage.
  4. Look for processes or scripts consuming excessive resources and consider optimising them.
  5. If your site regularly exceeds resource limits, you may need to upgrade to a higher-tier hosting plan.

Geographical latency can also affect responsiveness for domestic traffic. If your server is located overseas, Australian visitors may experience slower response times and timeouts.

Check Server Logs

Server error logs often contain specific details about why the upstream server failed to respond.

  1. Access your hosting control panel and open Error Logs or Raw Logs.
  2. Look for entries recorded around the time the 502 error occurred.
  3. Common entries include connection timeouts, PHP fatal errors, or database connection failures.
  4. Provide these log entries to your hosting provider if you need further assistance.

If the Error Persists

If you host your website with us, our Brisbane support team can investigate server-side issues for you. Just Open a Ticket.

Remember — If you host with us, you don't need to do this yourself — just Open a Ticket and our Brisbane team will get it sorted.

Still Having Issues?

Need more help? If the issue persists after trying these steps, please open a support ticket and our team will assist you.

💻 Open a Ticket