# 504 Gateway Time-out during POST

**URL:** <https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964>\
**Category:** NGINX\
**Created:** [September 7, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964 "2008-09-07T18:53:12Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 7, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/21 "2008-09-07T23:44:19Z")

</div>

Maybe not related but… when I tried to run phpMyAdmin under php-fpm  
and mysqli (notice it is a problem with MySQLi), I was getting random  
and very often 504 errors because the php was sigfaulting. I am pretty  
sure it is not an nginx problem but more the fact that you have PHP  
now running as fastcgi rather than mod\_php.

Please, take a closer look at nginx’s error log and if the server is  
not in production or just quickly run php-cgi without php-fpm like  
this:

php-cgi -b 127.0.0.1:9000

Do not make it go in daemon mode so that you can see on the console if  
it dies.

HTH,  
Kiril

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 7, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/22 "2008-09-07T23:44:19Z")

</div>

On Son 07.09.2008 21:30, David wrote:

> It’s vbulletin ([vbulletin.org](http://vbulletin.org))
> 
> BTW just a thought I had when looking at my php.ini …
> 
> I moved my MySQL to a different drive and moved my mysql.sock In  
> php.ini it looks like it’s looking at the wrong one, and  
> /var/lib/mysql/mysql.ini which I thought was symlinked but it’s  
> not. Could this be causing the speed problem ?

I don’t think so.

Do you have any information about the timing 😉

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:06am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/23 "2008-09-08T00:06:39Z")

</div>

I now have this in my nginx.conf is this what you meant ? Does this log  
to the  
same error\_log ?

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

```

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

log\_format timing '$remote\_addr - $remote\_user [$time\_local] $request ’  
'upstream\_response\_time $upstream\_response\_time ’  
‘msec $msec request\_time $request\_time’;

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 7, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/24 "2008-09-07T23:44:55Z")

</div>

[vbulletin.com](http://vbulletin.com)

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:15am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/25 "2008-09-08T00:15:26Z")

</div>

On Son 07.09.2008 21:58, David wrote:

> I now have this in my nginx.conf is this what you meant ? Does this log to the  
> same error\_log ?
> 
> log\_format main '$remote\_addr - $remote\_user [$time\_local] $request ’  
> '“$status” $body\_bytes\_sent “$http\_referer” ’  
> ‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;
> 
> log\_format timing '$remote\_addr - $remote\_user [$time\_local] $request ’  
> 'upstream\_response\_time $upstream\_response\_time ’  
> ‘msec $msec request\_time $request\_time’;

No you need to add this line in nginxs config file and send a HUP to the  
master process

access\_log logs/timing.log timing;

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:42am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/26 "2008-09-08T00:42:58Z")

</div>

On Son 07.09.2008 22:19, David wrote:

> This didn’t resort in a 504 but was a situation I can replicate over  
> and over with the server on 0.4 load averages:
> 
> xxx.xxx.xxx.xxx - - [07/Sep/2008:17:16:54 -0500] POST  
> /forums/private.php?do=insertpm&pmid=101373 HTTP/1.1  
> upstream\_response\_time 37.832 msec 1220825814.697 request\_time 37.833

Ok please can you increse the

max\_execution\_time = 40

to

max\_execution\_time = 80

add error\_reporting = E\_ALL

in php.ini and restart php-fm

and please can you add

$status

after

[$time\_local]

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:54am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/27 "2008-09-08T00:54:43Z")

</div>

I have done all that you asked.

Very, very, rarely that script will execute (it’s just sending a private  
message  
to another user) as it should - basically instantly.

I see sometimes fastcgi is logging the

I have just managed to recreate the 504 error and I can see no errors in  
my  
php-error-log file.

The 504 occured here:

[07/Sep/2008:17:44:24 -0500] 504 POST  
/forums/private.php?do=insertpm&pmid=101373 HTTP/1.1  
upstream\_response\_time  
60.000 msec 1220827464.227 request\_time 60.003

and in the nginx error\_log:

30104#0: \*43481 upstream timed out (110: Connection timed out) while  
reading  
response header from upstream, client

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:27am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/28 "2008-09-08T00:27:43Z")

</div>

This didn’t resort in a 504 but was a situation I can replicate over and  
over  
with the server on 0.4 load averages:

xxx.xxx.xxx.xxx - - [07/Sep/2008:17:16:54 -0500] POST  
/forums/private.php?do=insertpm&pmid=101373 HTTP/1.1  
upstream\_response\_time  
37.832 msec 1220825814.697 request\_time 37.833

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 9:27am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/29 "2008-09-08T09:27:20Z")

</div>

Also getting a lot of these:

Sep 07 17:16:00.585206 [WARNING] fpm\_children\_bury(), line 229: child  
27767  
(pool default) exited on signal 15 SIGTERM after 4734.359086 seconds  
Sep 07 17:16:00.585350 [WARNING] fpm\_children\_bury(), line 229: child  
27770  
(pool default) exited on signal 15 SIGTERM after 4734.355287 seconds  
Sep 07 17:16:00.585452 [WARNING] fpm\_children\_bury(), line 229: child  
27772  
(pool default) exited on signal 15 SIGTERM after 4734.352343 seconds

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 12:58am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/30 "2008-09-08T00:58:14Z")

</div>

I sometimes get these:

an upstream response is buffered to a temporary file  
/usr/local/nginx/fastcgi\_temp/0/00/0000000000 while reading upstream

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 11:17am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/31 "2008-09-08T11:17:05Z")

</div>

On Mon 08.09.2008 10:24, Kiril A. wrote:

> Try posting also to the PHP-FPM list. The author of PHP-FPM is very  
> well familiar with nginx and will be able to help you out here.

full ack

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 9:33am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/32 "2008-09-08T09:33:12Z")

</div>

Try posting also to the PHP-FPM list. The author of PHP-FPM is very  
well familiar with nginx and will be able to help you out here.

Kiril

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 11:20am UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/33 "2008-09-08T11:20:36Z")

</div>

On Son 07.09.2008 22:47, David wrote:

> The 504 occured here:
> 
> [07/Sep/2008:17:44:24 -0500] 504 POST  
> /forums/private.php?do=insertpm&pmid=101373 HTTP/1.1 upstream\_response\_time  
> 60.000 msec 1220827464.227 request\_time 60.003

You see here first the 40s in php.ini and now the 60s in php-fm config  
kills the process.

Please can you try to find out how long the task should run normaly!

You can try to set both values (request\_execution\_timeout,  
max\_execution\_time) to a high value and see how long the task run  
normally

Aleks

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/34 "2008-09-08T16:27:59Z")

</div>

You may want to try using spawn-fcgi just as a test to see if behaviour  
changes.  
Chris:)

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 2:27pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/35 "2008-09-08T14:27:12Z")

</div>

Thank you Kiril, I’ll do that. I wasn’t sure whether this was stricly an  
nginx  
or php-fpm issue, but it does sound more PHP related.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 9:22pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/36 "2008-09-08T21:22:22Z")

</div>

Aleksander,

You mentioned about securing php.ini and referred to:

[http://www.php.net/manual/en/session.configuration.php#ini.session.save-path](http://www.php.net/manual/en/session.configuration.php#ini.session.save-path)  
[http://www.php.net/manual/en/session.configuration.php#ini.session.entropy-file](http://www.php.net/manual/en/session.configuration.php#ini.session.entropy-file)

Can you please advise what these should be set to ?

Thanks

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 9:47pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/37 "2008-09-08T21:47:39Z")

</div>

Dear David,

I think this is now ot. I switch to personal mail.

On Mon 08.09.2008 19:13, David wrote:

> Aleksander,
> 
> You mentioned about securing php.ini and referred to:
> 
> [PHP: Runtime Configuration - Manual](http://www.php.net/manual/en/session.configuration.php#ini.session.save-path)  
> [PHP: Runtime Configuration - Manual](http://www.php.net/manual/en/session.configuration.php#ini.session.entropy-file)
> 
> Can you please advise what these should be set to ?

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 10:46pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/38 "2008-09-08T22:46:38Z")

</div>

On Mon 08.09.2008 13:00, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hei guys  
> do post your final findings here on how u fixed the problems!

Yes

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 9, 2008, 7:35pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/39 "2008-09-09T19:35:55Z")

</div>

Just an update …

Whilst I feel it may be too early to say this is resolved, I have made a  
lot of  
progress.

Tidying up the order of my sections in nginx.conf appears to  
have  
made the PHP execute as quickly as it should.

I’m going to give this a couple more days and will update in more detail  
should  
things stay as good as they are now.

Thanks again all for your help.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [September 8, 2008, 10:43pm UTC](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964/40 "2008-09-08T22:43:41Z")

</div>

hei guys  
do post your final findings here on how u fixed the problems!

[Previous page](https://www.ruby-forum.com/t/504-gateway-time-out-during-post/147964.md?page=1)
