Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

502 gateway timeout – A quick way to fix it

by | Apr 24, 2019

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.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

2 Comments

  1. Cecilia

    Please help
    502 gateway timeout.

    Reply
  2. Maheen Aboobakkar

    Hello Cecilia,

    If you are still facing the issues, we’ll be happy to talk to you on chat (click on the icon at right-bottom).

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF