# 504 Gateway Time out

**URL:** <https://www.ruby-forum.com/t/504-gateway-time-out/190091>\
**Category:** NGINX\
**Created:** [June 14, 2010, 6:02pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out/190091 "2010-06-14T18:02:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![insane](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/47e85d/32.png) [@insane](https://www.ruby-forum.com/u/insane)\
**Post date:** [June 14, 2010, 6:02pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out/190091/1 "2010-06-14T18:02:55Z")

</div>

I just switch between apache to ngix, after set it up everything ( the  
php and ngix ) everything is fine but only after certain amount of time  
i got 504 gateway time-out.

Form the error log i got is :

"2010/05/14 23:50:38 [error] 5024#4444: \*1985 upstream timed out (10060:  
A connection attempt failed because the connected party did not properly  
respond after a period of time, or established connection failed because  
connected host has failed to respond) while connecting to upstream,  
client : … "

I have been using the search here to find what will be the problem but  
most of the reply here is about increasing the

- max\_execution\_time
- fastcgi\_read\_timeout

from the task manager i can see php-cgi.exe were not there when the web  
got the 504 error. It seems been kill by something. I really think it is  
about the php.ini problems. For the time being i just increase the  
fastcgi\_read\_timeout to higher value because i do not know why does this  
happens.

Below is my nginx config. :

#user nobody;  
worker\_processes 1;

#error\_log logs/error.log;  
#error\_log logs/error.log notice;  
#error\_log logs/error.log info;

#pid logs/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;

```
#log_format main '$remote_addr - $remote_user [$time_local]

```

“$request” ’  
# '$status $body\_bytes\_sent “$http\_referer” ’  
# ‘"$http\_user\_agent" “$http\_x\_forwarded\_for”’;

```
#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
        root html;
        index index.html index.htm, index.php;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    # proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on

```

127.0.0.1:9000  
#  
location ~ .php$ {  
root html;  
fastcgi\_read\_timeout 180;  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME  
c:/nginx/html/$fastcgi\_script\_name;  
include fastcgi\_params;  
}

```
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}

```

rewrite ^/notice.htm /notice.php last;  
rewrite ^/home.html /index.php last;  
rewrite ^/(._).asp /index.php last;  
rewrite ^/index.html /index.php last;  
rewrite ^/(._).asp /$1.php last;  
rewrite ^/sig-(._)-(._)-(._).sig /sig.php?n($1)t($2)f($3) last;  
rewrite ^/(._).html /index.php?write=$1 last;  
}

```
# another virtual host using mix of IP-, name-, and port-based

```

configuration  
#  
#server {  
# listen 8000;  
# listen somename:8080;  
# server\_name somename alias another.alias;

```
# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers

```

ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
# ssl\_prefer\_server\_ciphers on;

```
# location / {
# root html;
# index index.html index.htm;
# }
#}

```

}

I really not good in php ( actually i just starting to learn it ) and  
setting this kind of things but i learn from the documentation, post and  
google for problems 😃

Anyway i hope i can get reply on this.

Thanks
