504 Gateway Timeout errors

I am getting 504 Gateway Timeout errors periodically on several sites. I am running on AWS and Digital Ocean Ubuntu 18 virtual servers. Bandwidth, RAM, CPU load, and disk space all show no issue. The virtual servers are websites are running WordPress with light to medium load. I sometimes see the 504 Gateway Timeout error trigger when a simple admin change is made s(uch as a post update) to one site or a relatively intensive page is accessed. Then, once the error starts, trying to view any page on the site, and in many cases any page on any website on the same server, also gives the 504 Gateway Timeout error. Usually it resolves itself after 5-30 seconds, however this downtime is still unacceptable.

Are there any steps to avoid this error to help prevent downtime?

Are there any steps to help one virtual server not affect other virtual servers? Sandboxing or limiting the resources to cap resource allowance?

Can you provide info about what your WordPress System Health Info settings are?

Happy to, but I’m not sure what settings you are referring to. Would you please elaborate?

In your WordPress Dashboard, go to Tools > Site Health > Info > Server

What info do you have in there?

Thanks. Here are the details:

Server architecture Linux 4.15.0-1056-aws x86_64 Web server Apache/2.4.29 PHP version 7.2.24-0ubuntu0.18.04.1 (Supports 64bit values) PHP SAPI cgi-fcgi PHP max input variables 1000 PHP time limit 600 PHP memory limit 256M Max input time 60 Upload max filesize 50M PHP post max size 50M cURL version Not available Is SUHOSIN installed? No Is the Imagick library available? No .htaccess rules Custom rules have been added to your .htaccess file.

Set your PHP time limit to 300, PHP memory limit to 128M and post max size to 256M. Your PHP post max size is very little and should be twice the amount of the PHP memory limit.

You can change those in Virtualmin via Example.com > Services > PHP Configuration > Resource Limits.

Thanks for the suggestion. Would you please elaborate on why you recommend these changes? And why should PHP post max size be twice the PHP memory limit?

It doesn’t have to be, it just has to be at least more than your PHP memory limit. This is probably why you keep experiencing issues.

This is strange.

My Example.com > Services > PHP Configuration > Resource Limits don’t match what I listed earlier in the server info. It says:
Maximum memory allocation 128M (not default)
Maximum file upload size 50M (not default)
Maximum input parsing time 60 sec (not default)
Maximum HTTP POST size 50M (not default)
Maximum execution time 30 (not default)

I even looked at Webmin > Others > PHP Configuration and it also shows the same values as this, except for for post_max_size = 8M and upload_max_filesize = 2M because I set that manually in the website php.ini file.

Do you know why there’d be this discrepancy?

Change this: Maximum HTTP POST size 50M (not default)

Set this to any value of :129M or higher.

error_log , other logs ?
does the timeout happen in some parts of the website or randomly?

i’d suggest installing php-curl too, seems not installed…