Question

Wordpress Site on digital ocean frequently returns 504 Bad Gateway

I had a similar issue in the past with a Laravel application and I was able to fix it by reducing the workload on pulling info from the DB.

But this time is a WordPress application hosted on Ubuntu 20.04 (LTS) x64 1 vCPUs 1GB / 25GB Disk I get this 504 Bad Gateway error 3-4 times daily and each time this error occurs, the site is down for about 5-10 minutes.

Here is the output from free -m

              total        used        free      shared  buff/cache   available
Mem:            981         741          69          80         169          40
Swap:             0           0           0

And the output I get from mpstat

Linux 5.4.0-51-generic (ubuntu-s-1vcpu-1gb-nyc1-01)     02/05/21        _x86_64_        (1 CPU)

21:59:40     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
21:59:40     all    3.59    0.02    1.17    0.63    0.00    0.06    0.02    0.00    0.00   94.52

And lastly the output from iostat 1

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.00    0.00    0.00  100.00

Device             tps    kB_read/s    kB_wrtn/s    kB_dscd/s    kB_read    kB_wrtn    kB_dscd
loop0             0.00         0.00         0.00         0.00          0          0          0
loop1             0.00         0.00         0.00         0.00          0          0          0
loop2             0.00         0.00         0.00         0.00          0          0          0
loop3             0.00         0.00         0.00         0.00          0          0          0
loop4             0.00         0.00         0.00         0.00          0          0          0
loop5             0.00         0.00         0.00         0.00          0          0          0
loop6             0.00         0.00         0.00         0.00          0          0          0
loop7             0.00         0.00         0.00         0.00          0          0          0
vda               1.00         0.00         4.00         0.00          0          4          0

Thanks

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, @supportAnemone

The issue is most likely related with the PHP-FPM service. The first thing I’d recommend, before we get started with the configuration, would be to tail the logs.

tail -n 50 /var/log/nginx/error.log

Also, let’s take a look at the PHP-FPM log, which should be in /var/log as well.

tail -n 50 /var/log/php$-fpm.log

Keep in mind that you need to select the fpm log for the PHP version in use.

You can also share the content of the php-fpm pool config file so we can check if we need to increase any of the settings like the pm.max_children because the issue is most probably related with the fact that the server have reached the pm.max_children limit.

Regards, Alex