504 Gateway Timeout Error and How to Fix It

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hey YouTube! This is Ruben and today I'll  talk about Timeout Errors and everything   you need to know about them. You will learn all  Error classes and how to work with Servers to   fix those timeout errors. Let's dive in! But  before we start troubleshooting your WordPress   size timeout errors, hit the ''Subscribe''  button and the bell to ''Get notifications'',   because we post new content every week .This  video was brought to you by 10Web, an Automated   WordPress Platform designed for agencies.  Automate Hosting, Speed Optimization, Migration,   Site Building and Management and Skyrocket  your agency growth. Sign up for a 14 day free   trial and experience through automation! First off  :''What is a 504 Timeout Error?'' As you all know,   a Website is all about sending requests  to the Server and getting Data back,   and every response from the Server contains an  http status code. And what is that? That's a   three-digit number where the first digit defines  the class of response. Here's the list of classes:   one: informational response: the request  was received and is being processed,   two: successful: the request was successfully  received, understood and accepted, three:   redirection: further action needs to be  taken in order to complete the request,   four: client error: the request contains  bad syntax or can't be fulfilled,   five: server error: the server failed  to fulfill an apparently valid request.   So error 504 belongs to the fifth class, where  the request is valid, but the Server can't fulfill   it. And why is that? Well, Timeout Error 504  usually happens when the Server is a gateway,   or proxy Server and can't receive a timely  response from the upstream Server. In human speak:   we waited for a reasonable amount of time  at the door of the Server and got no answer.   If there's some other issue, you will get  one of these. 500 Internal Server Error: this   wants a generic error message and has no specific  messaging. 501 Not Implemented: means the server   doesn't recognize the request method or lacks the  ability to fulfill it. 502 Bad Gateway: the Server   is acting as a gateway or a proxy and receives  an invalid response from the upstream Server.   503 Service Unavailable: means the Server is  temporarily unable to process the request,   because of an overload or it's down for  maintenance. Next question: "What does the Timeout   Error 504 look like?'' A trick question! It can  look any which way. Whenever you spot the number   504 and read something about gateway timeout,  there it is here's Google's, if it helps. So   what causes Timeout Error 504? As the class  of response shows it's a Server-side error,   but even though usually a user can't do much  here, there are still some things you should try.   Here's what you can do: wait a minute and reload  the page: maybe it's a temporary problem. Restart   network devices :if reloading the page doesn't  work, try to restart your device and your Network   devices such as modem or router, then reload the  page. Flash DNS cache: the problem may be your   DNS Servers: Linux, Windows and macOs save name  resolution information in the form of a DNS cache:   you can clear your DNS cache. For flashing cache  on Windows open Windows command prompt and type   the following: if you succeed, you will get the  successfully flush the DNS resolver cache message.   On macOs open the terminal and type this command!  There is no message after processing this command,   so you can add your own by running the command  in this way. Now cleaning a DNS cache on Linux   is different from macOs or Windows. Different  Linux distributions use different DNS services:   some of them are NSCD, (Name Service Caching  Daemon), Dnsmask and BIND (Berkeley Internet   Name Domain). Open the terminal and depending  on your own Linux distribution DNS Server,   use one of these commands to flush DNS cache  on Linux! For an DNS cache use this one.   This one is for Dnsmask DNS cache and  for a BIND DNS cache use these three.   If the terminal asks, enter your password. If it  doesn't help, try the next tip! If cleaning the   DNS cache didn't help, you can try changing your  DNS Servers: when you change the DNS Servers, that   your Internet connected device uses you change  your servers usually assigned by your ISP . If   you're using Cloudflare, note that Cloudflare  returns a 504 Error on a custom template,   when your origin Web Server responds  with a standard http 504 Timeout Error.   This is because something is wrong with your  Server. You can try to fix it with the steps   that we've already described and if that doesn't  help, you should contact your hosting provider.   If the 504 Error is from Cloudflare, the screen  may look like this. If the Error doesn't contain   the word Cloudflare, it means that the problem  comes from the actual Server. If the error does   contain the word Cloudflare, contact Cloudflare  support. The same goes for 502 Bad Gateway Errors.   Now what can you do on the server side?  To find out the reason for a 504 Error,   check your Server locks: by checking access  locks you can see if there's any Spam   from bots. You can also check error logs for  information about issues on your Website.   With 10Web you can easily do this by  going to Hosting services ,then logs:   you can select access logs, error logs ,PHP FBM  logs from the selection at the top of the page.   If you have access to your Server, you can check  Server logs. Depending on your Web Server type:   Nginx or Apache, the logs can be in /var/ log/  nginx or in /var lock /apache too correspondingly.   Now what are the possible Server related reasons  for 504 Timeout Error? One of the common reasons   is Server-side infrastructure. Many Shared  Hostings don't provide enough resources for   high traffic Websites, that is why we at 10Web  provide Automated WordPress Hosting powered by   Google Cloud allowing us to use Linux containers  to isolate the resources we provide to you   .So there are fewer 504 Errors. And if you do face  a 504 Error, try contacting our customer support   to resolve the issue faster! Another major  reason for a 504 Timeout Error is the number   of PHP workers, that is background processors  responsible for processing PHP code. If you have   only one PHP worker, your site can process only  one request at a time, but this doesn't mean that   the second request won't be processed. Instead the  PHP processes will be placed in a queue. If all   PHP workers are busy and the queue is full ,504  or 502 Errors may occur. So it's very important   to understand the exact number of workers that  will best serve your site's needs. Another   common reason for a 504 Timeout Error is improper  Firewall configuration. A Firewall is basically   a Network Security System, that establishes a  barrier between a trusted Network and an untrusted   Network. In some cases there can be such Firewall  settings, that can consider safe and valid content   as malicious and cut off traffic ,which can lead  to 504 Timeout Errors. So check your Server Error   Logs to find out if the Firewall has improper  configs! The next reason is bots and attacks.   Many requests from Bots or DDoS attacks by hackers  can lead to Timeout Errors . And to avoid this,   you can use Cloudflare ,which is a market  leader in DDoS protection. Another possible   reason for Timeout Errors is third-party plugins  and themes. Heavily working PHP scripts written   in a non-optimal way can cause Timeout Errors as  well. So try deactivating all plugins and start   activating them one by one to find out the  guilty ones! If you can't open your WordPress   Admin Dashboard because of the Error, but still  have file access to WordPress installation, just   rename the plugin folder in WP content: this will  deactivate all plugins. And for your theme you   can temporarily change your theme to WordPress is  the full theme to discover the issue. 504 Errors   can occur due to Cron jobs, that are running on  your Server doing heavy tasks. To check which   Crons are running, you can use the WP Control  plugin, which allows you to view and control   the WP Cron System. And if you have access to  WP-CLI, you can run this command to check Crons.   The result will be the following.   To avoid Timeout Errors, you can configure your WP  Chrome in a way that allows it to run like a real   Cron. Since WP Cron works during the requests, it  has max execution time limitation and so can lead   to Timeout Errors. Inefficient database queries  can also cause Timeout Errors. To discover such   queries you can use the Query monitor plugin,  which is a developer tools panel for WordPress.   Another useful tool to find Timeout Errors  is WP profile command package for WP-CLI:   this doesn't come with WP-CLI, so you have to  install it yourself. It gives you profiling   information about how long each step of your  WordPress Website loading process has taken.   If you have SSH access to your Website, you  can easily install it by running this command.   Next on our list of server side reasons is  WordPress imports: the plugins WP all import   and WordPress importer are widely used by  WordPress developers for importing XML,   CSV files and images to their Websites. If  the connection between the Server and the   Client is open for a long time during  import ,it can cause Timeout Errors.   To solve this problem you can import the  file by chunk, by dividing it into smaller   files. If you have access to WP-CLI, you  can try this command for importing a file.   And finally the reason may be Server configs.  Now let's take a look at Specific Server side   parameters! Increasing these parameters can help  you solve timeout issues. If you want to increase   max execution time for your PHP script ,change the  max execution time parameter in your php.ini file.   The default value of max execution time is  30 seconds. If your Website is running with   an Apache Web Server, you can change the  timeout directive in the httpd.com file.   If your Website is running with a standalone  Nginx Server with a fast CGI Process Manager,   you can open /etc/ php 7.4 fpm pool.d www.conf and  set it like this. If you want to increase the time   limit for a given site, open the following and  increase the fast CGI read timeout directive.   To increase the time limit for all Websites  open this Crone file and do the following.   After changing parameters don't  forget to reload PHP FPM and Nginx!   If you're using Nginx as a reverse proxy  Server for Apache, then you have to change   these directives in your nginx.com file.  After increasing parameters reload Nginx.   Now let's discuss a related error err connection  timed out! It means that Server is taking too much   time to reply. This error appears when your  Website is trying to do more than your Server   can manage. It's particularly common on Shared  Hosting , where your memory limit is restricted.   To fix this you can clear the Browser cache or  open the page in incognito private mode. Try all   steps mentioned under the section client-side  troubleshooting! You can also increase your   memory limit in wp-config php. If you don't have  access to your Server, you can ask your hosting   provider to increase your memory limit for you.  Or you can increase the maximum execution time in   your php.ini file as I described above or ask  your hosting provider .And finally let's talk   about cash! To avoid Timeout Errors you should  use caching on your Website. Caching has many   benefits: it improves Website performance and user  experience and reduces the load of your Hosting   Server. With 10Web you can enable it by heading  to Hosting Services, tools, then Website caching.   And even if you're not using 10Web, there are many  great caching plugins in the WordPress directory.   Hope you found our guide to troubleshooting 504  Timeout Errors helpful and don't forget to hit   the ''Like'' and ''Subscribe'' buttons to make  the most out of WordPress and grow your online   presence! This video was brought to you by 10Web,  an Automated WordPress Platform designed for   agencies. Automate Hosting, Speed Optimization,  Migration, Site Building and Management and   Skyrocket your agency growth. Sign up for a 14  day free trial and experience through automation!
Info
Channel: 10Web | AI-Powered Website Builder
Views: 102,491
Rating: undefined out of 5
Keywords: 10Web, 502 bad gateway, 504 error, 504 gateway time-out, 504 gateway timeout, 504 gateway timeout error, error 504, how to fix 504 gateway timeout error, how to fix error 504, http error 504
Id: 3qdLXE2nDOo
Channel Id: undefined
Length: 13min 26sec (806 seconds)
Published: Fri Apr 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.