Question

504 Gateway time-out, nginx, nodejs

First of all. The autorenew of my SSL certificate failed for some unknown reason. After re-installing the ssl certs from let’s encrypt, nginx gave me 504 gateway-timeout. I checked the error log and this appear.

2018/06/03 12:37:32 [error] 9128#9128: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 84.253.220.134, server: cloudland.com, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:3000/", host: "cloudlandmusic.com"

So I have nginx reverse proxy for a node js app. This is my nginx config:


# HTTP — redirect all traffic to HTTPS
server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;
}

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name cloudland.com;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/cloudlandmusic.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cloudlandmusic.com/privkey.pem;

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:3000/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}


My node app is running with pm2

this is the nginx status:

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-06-03 12:35:25 UTC; 16min ago
  Process: 8883 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 9122 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 9118 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 9127 (nginx)
    Tasks: 2
   Memory: 2.1M
      CPU: 66ms
   CGroup: /system.slice/nginx.service
           ├─9127 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─9128 nginx: worker process

But I think nginx is not the problem, for some reason my app is not working, but I don’t know how to debug it, thanks for any help


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This happens due to lack of RAM…check this by using pm2 log or pm2 monit commands…