A “502 gateway timeout” is a common server error that leads many of our customers to headache.

This error happens when one web server gets an invalid response from another web server.

There are many reasons for this error to happen, such as Bad server settings on DNS, PHP timeout settings and much more.

Here at Bobcares, we often get requests from customers to resolve server errors as part of our Technical Support services.

 

What is 502 Gateway timeout error?

A HTTP response code “502 gateway timeout” error indicates an invalid response from a back-end server to the edge server.

This “502 gateway timeout” error happens if it takes more time to execute requests on the backend server. In addition, it may happen due to incorrect DNS settings, firewall blocks proxy server request and back-end server down.

Now, let’s see how our Support Engineers fix “502 gateway timeout” error.

 

 

How to fix 502 gateway timeout error

From our experience in managing servers, we often see that customer experiencing a tough problem like 502 gateway timeout error.

Now, let’s see how our Support Engineers solved such problems.

 

DNS Issue

A 502 gateway error may occur due to the DNS issue, such as the domain is not resolving to the correct IP.

For example, one of our customers migrated the WordPress site to a new host. After that, he had an issue as “website not loading”.

1. Then our Support Engineers checked the DNS settings of the website by using backend command utility like “dig”.

dig bobcares.com

2. From that, they could analyze that the domain is not resolved to the correct IP.

3. We updated the correct IP address for A record in WHM >> Home >> DNS Functions >> Edit DNS Zone.

Also, we asked customers to wait up to 48 hours for the DNS record to propagate completely.

That fixed the issue and the customer could access the site.

 

PHP Timeout Issue

The PHP timeout issues may cause 502 timeout error. Again, this error occurs when a single PHP process runs for more than the max_execution_time or max_input_time.

In order to solve this issue, our Support Engineers have altered the PHP timeout values in the PHP settings on the server.

In Apache on Ubuntu, we took the following steps to edit php.ini for altering the PHP timeout values.

1.  We edited the file php.ini

nano /etc/php5/apache2/php.ini

2. Then, we found the line for “max_execution_time”, which defines how many seconds a PHP process can run for.

3. We increased the value and saved the changes.

max_execution_time = 30

4. Finally, restart the service.

service apache2 restart

 

Firewall blocks request

In most of the servers, the firewall is installed by default.

Sometimes, it blocks the communication between the edge servers and the back-end server. In addition, some server has region-specific IP restriction too. This results in an error like 502 timeout error.

Here, our Support Engineers rebuild the server firewall in such a way that it does not create a security risk for the server.

 

Problems with web browser

Sometimes this error may happen due to the problems with the web browser. You can fix this error from your side by doing the following steps.

  1. Clearing cache of the web browser.
  2. Delete your browser’s cookies.
  3. Start your browser in Safe Mode.
  4. Try another browser.
  5. Restart your computer.
  6. Restart your networking equipment such as modem, router, switches.

 

[Getting 502 gateway timeout” error? We are here to fix it.]

 

Conclusion

In short, a HTTP “502 gateway timeout” error is a response code. It occurs when users attempting to visit a web page, but the edge server receives an invalid response from back-end web servers. Today, we saw how our Support Engineers solved the error 502 gateway timeout.



Source link

Author

Write A Comment