Nothing is as frustrating as getting a timeout error when accessing a web page or application. You would think in our highly-digital world, everything should work seamlessly, but alas, things still break (or appear to be broken) for no explainable reason whatsoever.
The relationship between the client, web application, web server and other 3rd parties can get somewhat complicated.
Every time you access a web server or application, you send an HTTP request to the server. In return, the server responds with an HTTP status code. If you’ve ever gone on a computer, which presumably you have since you’re reading this article, you’ve probably run into something like this:
With over 50 HTTP status codes, it can be a daunting task to find the cause of your error.
HTTP status codes are three-digit codes that web clients and servers use to communicate and exchange information. They fall into 5 different classes:
- 1xx: Informational – this means the request was received and the process will continue. Unless the connection between a proxy and its client terminated, proxies have to forward these responses.
- 2xx: Success – this lets the client know it got the request, it understood it, and the request was accepted.
- 3xx: Redirection – these status codes are used for when requested resources moved, and further action needs to take place.
- 4xx: Client Error – these are status codes for situations in which the client causes the error.
- 5xx: Server Error – this means the server failed to deliver what it was supposed to.
What are timeout errors?
When a server takes too long to reply to a request made from a client or another server, the connection has timed out and is considered incomplete or failed. The device that made the initial request for data (e.g. using a Web browser to access a site) has “given up” on waiting for the requested information, and a timeout occurs. The purpose of server timeouts is to prevent us from wasting our time waiting for a response that we will most likely never get.
Why Timeout Errors Occur with Your Proxies
Timeout errors can happen for a variety of reasons, but unfortunately, we’ll never really know why. Receiving an error message doesn’t help us determine why the error happened. It could be the web server, the requesting client, the network infrastructure, the web application or even just a bad internet connection.
Generally speaking, a response status in the 4xx category is a client error response and those in the 5xx category are server error responses. However, don’t take that for face value. A 4xx error code could be a result of a server-side issue.
You can read more about what causes timeout errors here
Types of Timeout Errors
408 Request Timeout
As mentioned above, an error in the 4xx category usually means the problem is on the client side. If you receive a 408 error on the web page, it means you, the client, did not receive a completed request by the server within a specified time (i.e. the timeout period) and as a result, the server has decided to close the connection rather than continue waiting. If you receive this error, take a look at URL you’re inputting. An incorrect URL is one of the most common causes of a 408 timeout error. Depending on the URL you are requesting, you could unintentionally be requesting something you don’t have access to and as a result, its routed through a separate proxy server used to handle user authentication.
502 Bad Gateway
This error message indicates that the gateway or proxy server is not receiving a valid response from the backend servers. There could be a handful of reasons you can receive this error message:
- The domain name is not resolving to an IP or not the correct IP
- The origin server is down or has no connectivity
- There is a firewall blocking communication between the edge servers and the origin server
- There was a server overload causing a crash
- Poor programming in the website’s code that can’t answer requests correctly
- The server is taking more time to complete and has reached its timeout values
- Network issues – DNS issues, routing problems and ISP related issues
When using a reverse proxy server or a load balancer, you’ll want to check that its configured correctly with the proper backends specified and the network connection between the backend servers and reverse proxy server is healthy. If the servers can communicate on other ports, you’ll want to make sure a firewall isn’t blocking traffic.
503 Service Unavailable
If a scheduled maintenance or a temporary overload occurs while you’re trying to access the site or application, the server is typically unable to handle the request and as a result, you’ll see a 503 error. In general, you should expect this resolved within some time.
504 Gateway Timeout
This error code means that the gateway or proxy server did not receive a timely response from another backend server that it was accessing while attempting to fill a request from the client. This issue is usually a network error between the servers such as a silent firewall drop or an issue with the actual server – either it’s down or not working.
Troubleshooting and Preventing Proxy Timeout Errors
Whether you are the website administrator or a user attempting to access an application or website, there are a variety of things you can try to fix the issues.
Troubleshooting from the Client Side
- Refresh the page – it could just be a temporary error that quickly got resolved
- Start a new browser session – it’s possible that the error occurred sometime during your use of a browser. If you’re the type that has a million tabs open and never closes the browser, it may be healthy to refresh a new session
- Clear your browser’s cache – outdated or corrupted files stored in your browser could be triggering this error
- Delete your browser’s cookies – just like clearing your browser’s cache, deleting cookies can help solve the error
- Start your browser in Safe Mode – this allows you to run the site or application in default settings without any extensions or add-ons
- Use a different browser – if you are able to access a page or an application in a different browser, you’ve identified that you’re browser is the culprit and you should uninstall/reinstall it
- Restart your computer – a reboot seems to always fix errors
- Restart your network equipment – if a computer restart didn’t do the trick you might want to do a hard reset to fix the errors
- Change your DNS servers – some errors are a result of DNS issues. Change your DNS servers on either your router or computer to see if that fixes the problem
- Come back later – it could be that the issue is known and the web administrators are working to resolve it
- Check the proxy server settings – make sure it’s correct. Go to proxy.org for an updated, respected list of proxy servers to choose from
- Contact the website administrators – chances are they are already aware, but if it hasn’t been resolved in some time, it may be a good idea to contact the website directly
- Contact your ISP – if after all of this, nothing has fixed the error, it could be a network issue that your ISP is responsible for
Troubleshooting From the Server Side
As a website owner or application operator, it’s in your best interest to fix timeout errors as quickly as possible and prevent them as much as possible. If not, you run the risk of unhappy users, loss of traffic, and potentially penalties by search engines.
You’ll want to begin with a ping or traceroute on the origin server. This will indicate whether the server is reachable and if not, a traceroute will help you identify where in the packet’s path are issues. Running a traceroute from the origin server to your IP can also be helpful to identify any communication issues.
Use a DNS test tool to see if your FQDN (fully qualifying domain name) is resolving correctly and then check your firewall logs for any errors.
Confirm Your Server Configuration & Change Your Timeout Settings
Although typically a 408 error is on the client side, servers can be the culprit so you’ll want to do your due diligence in finding the cause. It could be that the server is misconfigured or has other routing issues.
Most proxy servers have a pre-configured time in which they’ll wait before timing out. Typically it ranges from 1-2 minutes. However, good news for developers is it can change. Most applications run on either Apache or Nginx. To determine which server your application is on you’ll need to look at a key file. If it is Apache, you’ll look for a .htaccess file within the root directory. In this file, you’ll see a KeepAliveTimeout (which is part of the core module) and the RequestReadTimeout. By adjusting the RequestReadTimeout header and body timeouts, you can extend the time servers have to retrieve and deliver the request.
If your application is running on nginx you’ll need to look for a nginx.conf file and locate the client_body_timeout, client_header_timeout or keepalive_timeout directives and adjust them accordingly.
Look through both files to see if there are any strange timeout directives and temporarily comment them out and restart your web server to see if that was the issue.
Error responses can be a real pain but with the right tools and settings, you can minimize the number of proxy timeout errors that occur and continue navigating through the digital world seamlessly and error free.