HTTP Error 502 - what causes it and what is the solution?

Author: HOSTTEST Editorial   | 3 Sept 2021

Error 408The reason why the Hypertext Transfer Protocol (HTTP) has become a standard for transmitting web pages since the 1990s is partly due to an integrated mechanism for preventing data and transmission errors. Each request is responded to by a web server with a status or error code to ensure correct communication and facilitate error source identification. A 500 error code like the 502 Bad Gateway error indicates a faulty configuration or temporary server overload, signifying that data transfer fails due to a serious issue in the current situation.

What causes a 500 error code?

The HTTP protocol recognises five different status codes, categorised based on the first of three digits. The range of numbers from 1XX to 3XX in this concept represents the confirmation of a successful operation or additional information such as a pending request or temporary and permanent redirections to another resource or address. The initial digit 4XX denotes (mostly) problems caused by the client, while a 500 error code indicates a cause by the web server. The most common variants include:

  • Error 500 Internal Server Error for unspecified, unexpected server errors
  • Error 501 Not Implemented for missing functionalities such as an unsupported HTTP method
  • Error 502 Bad Gateway for a server communication breakdown
  • Error 503 Service Unavailable for a (temporary) server outage
  • Error 504 Gateway Timeout indicating a timeout exceeding the permissible limit
  • Error 508 Loop Detected for a loop in the query
  • Error 509 Bandwidth Limit Exceeded in case of exceeding the allowed bandwidth
  • Error 511 Network Authentication Required requiring network authentication

Although a 500 error code can indeed be triggered by faulty configuration or unexpected client behaviour, in most cases, the issue lies on the server side.

When does the 502 Bad Gateway error occur?

The error 502 Bad Gateway - sometimes specifically referred to as Bad Gateway NGINX or Bad Gateway Apache after the web server - is likely one of the most common causes of data transfer failure following the error code 404 Not Found. The reasons for its occurrence are diverse and include:

  • Complete failure of the web server, such as system crashes
  • Temporary overload, for example during a DDoS attack on a website
  • Consistent errors in communication between server and client
  • Request failures due to bugs in PHP programming
  • Browser extensions preventing or disrupting correct data transmission
  • Network blocking requests, for instance by a strict router firewall
  • A third-party instance - like a VPN or proxy - preventing bilateral connection

At first glance, a 502 Bad Gateway error may seem clear-cut - unfortunately, technically it simply indicates that a query fails at a specific point of communication because the server cannot provide or output plausible responses.

How can a 502 Bad Gateway error be resolved?

For visitors to a website, the options to resolve a 502 error are often limited. In many cases, it is a temporary disruption caused by maintenance or short-term overload. To rule these out, some simple steps are recommended:

  • Accessing with an alternative browser and - if possible - operating system
  • Disabling extensions and plug-ins like UBlock, Ghostery, or AdAway
  • Clearing the cache to remove outdated data
  • Deleting all cookies from the relevant site and third-party providers used

If these steps do not succeed, the issue lies with the requested web server and must be checked and resolved by the appropriate administrator of the web hosting. Visitors still have certain ways to access a page when encountering a 502 error, although functionality may be limited in this case.

How can a website be accessed after encountering a 500 error code?

If an error code 500 like the error 502 Bad Gateway occurs, it means that the server is currently unreachable. There are two options available to access a non-login or other restricted webpage independently of the configuration of the relevant virtual or dedicated server. However, this will be an archived version that does not allow further interaction such as logging in.

Google stores website content in its cache for a specified period and can retrieve it directly from there. To do this, the user simply needs to enter cache: before the address - for example: cache:https://example.org/webpage.

The second option is to use an internet archive like the Wayback Machine. These mostly non-profit projects save content at regular intervals as so-called snapshots and make them publicly available.

Photo: Gerd Altmann from Pixabay

Write a comment


More web hosts


More interesting articles

HTTP 504 Gateway Timeout: Causes and Solutions of Error 504

We explain the server error 504 including approaches to solutions. We are here to help!

HTTP Error 400: Where are the causes and the solution?

HTTP Error 400: We show you how you can fix the error.

Too Many Requests - what is error 429 and how does it occur?

Too Many Requests is not a popular error. We tell you how you can avoid it.

What is an HTTP Request? Simply explained

We simply explain what an HTTP Request is.

Status code 302 - what does it mean and how does it affect?

The status code 302 should only be used in a few cases. We show you where its use makes sense.

Server Error 500 - Causes and Solutions of the Problem

We explain the server error 500 including approaches to solutions. We are here to help!