You might be facing the Nginx 504 gateway time out error due to various reasons, so let’s see what is causing the 504 gateway time out error in Nginx.
Factors causing Nginx 504 gateway time-out error:
Check your back end server: If there are too many requests or if there are any long-running requests, then your server gets overloaded which, causes 504 gateway time-out errors. Even though this gets fixed automatically when the server load gets balanced, make sure you check your server logs to identify the requested URLs just before your server went down.
Client-side or Server-side DNS issue:
Client-side: You can try flushing the local DNS cache.
Server-side: On your server-side, if you would have changed or migrated your website IP address, then the DNS record would take 5 min to 24 hrs to get updated.
Website with CDN: If your website has CDN implementation then it can be a timeout causing NGINX to return 504 Gateway Timeout errors. If this occurs, then you can disable your CDN and try accessing your website.
Network Connectivity: If there are network connectivity issues between your reverse proxy server and back-end web server, then you would see NGINX 504 Gateway Timeout error. You can log into your proxy server and try to connect to your web server using the curl/ping command to irradiate this error.
Server’s firewall Issue: Check whether your web server’s firewall has been configured properly or not, as it might block many requests which causes NGINX to give a 504 Gateway Timeout error.
Check for Spam, Bots, and DDOS attack: Some malicious attackers may flood your web server with too many requests, or it can slow your running requests. You need to keep monitoring your server log to identify if there is any spike in traffic, if so, you need to identify their IP address and put measures to regulate their incoming requests.
We at actsupport, provide Server Monitoring on a 24/7 basis, where you get updates and alerts on time. You needn’t spend your time and energy worrying about your server maintenance, while we take care of your servers.
Bugs & faulty plugins configuration: Application bugs, faulty plugins, and poorly configured modules can also slow down your server, which causes NGINX to return 504 Gateway time-out errors. Check server logs to find out which requested URLs are causing the issue so that you can fix them.
You can check: Nginx on cPanel – Quick set up guide of Engintron