If you are a frequent internet user, then there is a high chance that you have encountered the HTTP error 504 once or twice. This is one of the oldest and most problematic errors for the website users. Even though most of the time HTTP error 504 automatically disappear after a few seconds, but in some cases, it sticks around in the device display and gives a headache to the user.
This is a little bit complicated issue because it can’t be solved by regular basic methods such as reinstall application or restart device. Fixing this problem requires a good amount of knowledge about proxy server and setting. If you don’t know how to get rid of the problem, then no need to worry because in this article, we are going to give you a complete guide on how to resolve error code 504. It also includes a brief explanation about the error, why it occurs and how to solve it. So, if you are interested to know all about this particular gateway error, then follow the rest of the article carefully
Brief Explanation About HTTP Error 504:
When you visit any website, it generates a request and sends them to the web server that holds the required element. After receiving the request, the server sends back an HTTP status code with the requested resources.
504 Gateway Timeout Error is an HTTP response status code. This error notification pops up when the server which is currently acting as a gateway or the proxy does not receive a timely response from the upstream server to complete a request. In short, the error code 504 display when the server was unable to complete the request that you have made in the given time frame. Exactly what 504 error notification will display depends completely on the website operator. Some of the frequently used error notifications are:
- HTTP 504.
- HTTP Error 504: Gateway Timeout.
- Gateway Timeout (504).
- Gateway Timeout Error.
- 504 Gateway Timeout.
- 504 Error.
- Error 504 Gateway Timeout.
Common Reasons Which Led to HTTP Error 504 Notification:
As we have discussed above, 504 error occurs when a network interface cannot respond to the browser’s request at a specific time. But why exactly does that happen? Well, there are a number of reasons which can cause this particular problem. In the below section, we have discussed about some of them. So, go through it to find out why you are facing the issue.
- If the proxy server or router that you are using as a local network is crashed for the excessive load or for other reasons, then the local network will stop working and display the error notification. In this case, the 504 gateway error will not be limited to a single website, but will also occur when you try to open the other web pages using the same network connection.
- Sometimes the incorrect proxy settings, in both on the client’s side as well as the server’s, can be the reason for the appearance of an HTTP 504 message.
- When you launched a website, it will return to a proxy server but when this server is overwhelmed, it will no longer be reached by prefixed internet nodes and can lead to the error 504 notification.
- If the problem affects one or several of an internet provider’s or company’s servers, then it means that the inaccessibility has nothing to do with the browser user’s router or proxy settings. In this kind of cases, the main problems lie at the end of the operator of the website.
Know the Best Methods to Fix Error Code 504:
The error 504 can become a massive problem for the users if the server is being used for important business work. If the important work is done with a cloud application, then there will be no offline alternative option will be available for you. Also, if you are a website owner, then this problem can result in a massive loss of traffic and can damage your turnovers. That’s why it’s very important to solve the problem quickly. For this reason, we have done a little bit of research on the topic and find several working solutions. So, choose the most appropriate method depending on the root cause of the issue and then start the troubleshooting process.
Method #1: Repair the Timeout Value (Nginx Server)
When the HTTP error 504 first occurred in your device, then the first thing that you should consider is changing the timeout value of your proxy server. The correct value of proxy server depends on which server you are using. It’s hard to provide a guide of each type of proxy server so we have used one of the most used servers as an example which is Nginx.
To use this method, add the following directives in the nginx.conf:
Once the values are added, save it and then reload the server. If you are using Nginx with the combination of FastCGI (PHP-FPM), then you need to perform further changes in the PHP-FPM, nginx.conf and php.ini file.
- At first, you need to perform changes in the PHP-FPM file by navigating to the below-mentioned path:
The path may be different for you depending on the PHP version you are using. Once you have open the particular file, set the following directive;
request_terminate_timeout = 300
- After that, you have to make changes in the php.ini file which you can find by going through the following path:
Once the file opens, search for the max_execution_time directive. If the directive is already set, then just change it’s value to 300. Otherwise, you have to add the max_execution_time = 300 directive in that file location.
- Finally, you have to modify your nginx.conf file in order to increase the value of fastcgi_read_timeout directive. To apply the settings to all the sites of that server, you have to add this directive,
fastcgi_read_timeout 300; …
If you want, then you can also modify the settings for a specific site.
Once the above changes are made, simply reload Nginx (service nginx reload) and PHP-FPM (service php5-fpm reload). After that, check i the problem is solved or not.
Method #2: Check Web Application’s Server Side Logs
All the web application keep some sort of server-side logs in their database. Application logs contain the past activity of the application’s activity. For example, if you are looking for information such as which pages were requested, which servers it connected to, which database results it provides, then you can get all of it in the application logs. Server logs are connected to the main hardware, which is running the application. That’s why it able to provide all the details about the health and status of all connected services as well as the server.
So, if the above method does not work for you, then the next thing you should do is check the error log to make sure if the recent changes or updates in the website causing the error or not. There are different methods available to activate the error message logging. In this article, we only provide a guide for the WordPress website as an example.
To activate the error message logging for WordPress, add the following line in the wp-confg.php file:
define( ‘WP_DEBUG’, true );
defne( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );
After adding it, all the generated entries will appear in THE wp-content/debug.log file. Now, simply check them to find the reason for the problem and how to get rid of it.
Method #3: Use Another DNS Server
In all the device, ISP sets the DNS servers that you utilize by default. These servers help your device to connect with the different servers on the internet. For some reason, if the DNS server that you are using is crashed or not up to the standard, then it can also trigger the error 504 notification. The best way to solve the issue is by changing the DNS server that your device is using. If you don’t know how to set the DNS server manually, then follow the below guide:
- First, click on the Start menu and then click on the Control Panel to select the Network and Internet section.
- Once the new window opens, click on the Change Adapter Settings. Then, right-click on the Wi-Fi network you are connected, to select the Properties option.
- After that, locate and select the Internet Protocol Version 4 or Internet Protocol Version 6 and click on the Properties option again.
- Now, write down any existing DNS server entry for future reference. Then, click on the “Use the Following DNS Server Addresses“ option.
- Now, simply replace those addresses with the 126.96.36.199 DNS address:
- For IPv4: 188.8.131.52 and 184.108.40.206
- For IPv6: 2606:4700:4700:1111 and 2606:4700:4700:1001
- Once the above changes are made, click on Ok and then hit the Close button.
Now, simply restart your browser to check if the problem is fixed or not.
Method #4: Deactivate Plugins (WordPress)
If the problem is website specific such as HTTP error 504 for WordPress, then you can consider disabling the plugins to get rid of the issue. In most of the cases, 504 gateway error occurred for WordPress website. That’s why we have decided to provide a separate solution for it.
WordPress is built using the PHP web language. It means plugins can interact with the platform only using the PHP language. But PHP can only handle a limited number of requests at a time. So, if a plugin making too many requests, then it can crash the server and cause a 504 Timeout error. To fix this issue, you just need to disable all the plugins one-by-one to find the main problematic plugins among them. But you can’t access your dashboard normally. To disable the plugins, it required File Transfer Protocol or FTP to do it. To use FTP, you’ll require the FTP credentials and a client such as FileZilla.
- To use this method, first install the client and then look for your 000Webhost credentials.
- In order to find the credentials, you have to log into the portal’s dashboard and then go to the Settings and General tab.
- After that, locate the section called FTP details to look for information such as your Host Name, Port, and Username
- Now, open your FTP client and type this information into the login bar at the top of the screen.
- After that, click on the Quickconnect button to the right. Make sure you use the same password which you use for your 000 web host account.
- When the client establishes a connection to your server, you will see two folders in the lower-right side of the screen.
- Now, click on the folder label as public_html ( The root folder of WordPress) and once you’re in, navigate to the wp-content/plugins directory.
- Here you’ll find individual folders for all the plugin installed on your WordPress account. Now, start to disable the active plugins one-by-one via FTP. After disabling a folder, rename the plugin’s folders to keep on track which folder you already have modified.
- After changing the name of each plugin, try reloading your website to check if the error is resolved or not.
If the 504 error disappears using this method, then we recommend trying contacting the developer of the plugin to fix the issue or replace it with another plugin service.
Method #5: Advanced Method
There are also some methods available which are less effective on this particular issue. But you can try it as a last option if the above methods didn’t work for you. These are:
- If you are using a content delivery network to improve your website’s load time, then you can try disabling it to see if it resolves the error
- A corrupted database can be the root of showing up the error 504 error notification. So, in that case, you can install a plugin and repair/optimize the database to see if that helps
- If there is no problem in local setup and domain, then it can be possible that issue lies with your hosting provider. If that’s the case for you, then you’ll need to contact your web host to ask them to fix the issue on their end.
Hope this article was able to solve your query related to how to fix HTTP error 504. We try our best to provide all the working solutions in this article. But somehow if we forget to mention any effective method, then feel free to write in the comment section. We will update the article as soon as possible. Also, if the above methods are unable to solve the issue for you, then we will highly recommend contacting an expert for better guidance.