504 gateway timeout while runnning the Load Test jmeter 504 gateway timeout while runnning the Load Test jmeter nginx nginx

504 gateway timeout while runnning the Load Test jmeter


Most likely your Nginx server is overloaded therefore request cannot be processed in the timely fashion causing the error.

It might be caused by several issues:

  1. Nginx server simply lacks hardware resources (CPU, RAM, Network or Disk). Make sure it has enough headroom to operate by monitoring the aforementioned resources on Nginx side using i.e. JMeter PerfMon Plugin
  2. Nginx server configuration is not suitable for high loads. Default configuration might not be suitable for handling 500 concurrent users so check out How to Configure nginx for Optimized Performance article to see whether your setup matches recommendations. Basically you need to combine points 1 and 2 to get most of your Nginx setup, if the machine is relatively idle and you're getting high response times and/or low throughput - something is wrong either with your web application or with infrastructure setup.
  3. It might be a problem with your application which cannot generate response faster than Nginx times out. Check out its logs and inspect what's going on using profiling tools - it will allow you to detect where application spends the most of time
  4. It might be an network infrastructure problem, i.e. you're using WiFi instead of LAN or there is a faulty router or you reached the limits of corporate proxy. It might be also a good idea to capture network traffic using a sniffer tool like Wireshark

But first of all read logs: JMeter logs, Nginx logs, OS logs, whatever exists and relevant. Most probably you will figure out the cause from them.