So, we're using Node.js to power CompassionPit.com, and it's all served up by nginx.

nginx is throwing a 504 Gateway Time-out

The interesting thing, however, is that if I navigate to http://compassionpit.com/index.html, then I can access the page (I believe the requested is routed through the Node app which is running on port 8000).

And http://compassionpit.com/blog/ is working.

But http://compassionpit.com/ is down. :(


root@li70-243:~# cat /etc/nginx/sites-enabled/blog
server {
    listen       80 default;                # your server's public IP address
    server_name  compassionpit.com;
    index        index.html;

    location /blog/wp-content/ {
        alias /opt/blog/wp-content/;

    location /blog/ {
        root /opt/;

        include        fastcgi_params;
        fastcgi_pass   localhost:8080;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

    location / {
        alias /opt/chat/static/;

        if (-f $request_filename) {
        if (!-f $request_filename) {


root@li70-243:~# cat /etc/nginx/nginx.conf 
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;

http {
    include       /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

root@li70-243:~# free
             total       used       free     shared    buffers     cached
Mem:        509868     394168     115700          0      43540     215296
-/+ buffers/cache:     135332     374536
Swap:       524284          0     524284
  • It's also possible that the Node app died...or is only partially working
    – Zachary Burt
    Apr 28, 2011 at 7:57

2 Answers 2


Try this instead of your location / :

location / {
    alias /opt/chat/static/;
    try_files $uri @nodejs;

location @nodejs {

And always inspect error.log, it's your best friend.


I also found out that csf on Linux was banning the node executable for many connections. The solution for this would be to add the node pid to the csf.pignore, like this (I've also included the PM2 path):

... exe:/usr/local/bin/node exe:/root/npm/lib/node_modules/pm2/bin/pm2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .