Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, we're using Node.js to power, 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, then I can access the page (I believe the requested is routed through the Node app which is running on port 8000).

And is working.

But is down. :(


root@li70-243:~# cat /etc/nginx/sites-enabled/blog
server {
    listen       80 default;                # your server's public IP address
    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/;

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
share|improve this question

migrated from Aug 22 '11 at 19:36

This question came from our site for professional and enthusiast programmers.

It's also possible that the Node app died...or is only partially working – Zachary Burt Apr 28 '11 at 7:57
up vote 2 down vote accepted

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.

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.