How to Fix 504 Gateway Timeout Error
Many at times as Software developers/engineers we face this kind of error most especially when :
- You have an overload or heavy traffic on your server,
- You have downtime in your app
- Your app is not responding within the server specified response time (usually 30 seconds).
It might be so annoying that lots of hours, even days would have been bygone trying to fixing this kind of error. Rejoice because you will never spend much time trying to fix this error again. Before we dive into the solution, let us understand what the error is all about.
In HTTP request any status code starting with number 5 is server-based. These errors are shown in the image below.

If your app is confirmed running and that there’s no downtime, to solve this error, you simply have to increase your server resources. For PHP-FPM there’s a setting you need to adjust in the file below:
/etc/php/7.2/fpm/pool.d/www.conf
Locate and update then below from its initial default values.
PS If your server has more load and capacity you might want to increase these settings.
pm.max_children = 500
pm.start_servers = 100
pm.min_spare_servers = 50
pm.max_spare_servers = 100
pm.max_requests = 500
request_terminate_timeout = 30s
Once this is done, save the file and restart PHP-FPM.
Thank You for reading and please don’t forget to clap for this post.