Getting 504 GATEWAY_TIMEOUT NodeJs Getting 504 GATEWAY_TIMEOUT NodeJs express express

Getting 504 GATEWAY_TIMEOUT NodeJs


In your .ebextensions config file, add the following code:

container_commands:  change_proxy_timeout:    command: |      sed -i '/\s*location \/ {/c \              location / { \                  proxy_connect_timeout       300;\                  proxy_send_timeout          300;\                  proxy_read_timeout          300;\                  send_timeout                300;\              ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf


From your Update3 information, I think you should config your nginx configure file, like:

server {    listen  80;    server_name     *.*;    location / {            proxy_pass http://192.168.0.100:8001;            proxy_connect_timeout 60s;            proxy_read_timeout 5400s;            proxy_send_timeout 5400s;            proxy_set_header host $host;            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            proxy_set_header X-Real-IP $remote_addr;            proxy_redirect default;    }}

proxy_read_timeout and proxy_send_timeout is related to your problem.


Normally when a job takes more than 30 seconds or 40 seconds, I usually notify the user that is executing and then I create a process to work with the database instead of a normal request to the server to avoid the user to wait for the request and to avoid that timeout problem, you can try this for example when you set the server to listen to a specified port:

//Create server with specified portvar server = app.listen(app.get('port'), function() {  debug('Express server listening on port ' + server.address().port);});//set timeout timeserver.timeout = 1000;