# Proxy returns 504 then blocks next connections

**URL:** <https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739>\
**Category:** NGINX\
**Created:** [July 11, 2013, 9:55pm UTC](https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739 "2013-07-11T21:55:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [July 11, 2013, 9:55pm UTC](https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739/1 "2013-07-11T21:55:53Z")

</div>

I’m having an issue where I proxy a long running script and receive a  
504  
error when it exceeds my proxy\_read\_timeout setting. All of that’s  
behaving  
normally – what isn’t behaving normally is that the next several  
requests I  
make to the domain via the same proxy code also return 504s after timing  
out, despite the fact that the request should complete properly.

The first script that runs takes approximately 10 minutes to run and,  
once  
it completes on the origin, the server again takes connections. The  
oddest  
part is that all of this is specific to the web browser calling the  
pages on  
the server. If I access the long running script in Chrome, I can no  
longer  
access another page through the proxy until the script finishes on the  
origin. Meanwhile, I can access pages without issue on Firefox or IE. If  
I  
run the script through Firefox, it becomes locked out but Chrome and IE  
work  
fine.

Here are the relevant proxy lines:

proxy\_cache CACHEFOLDER;  
proxy\_cache\_use\_stale updating error timeout invalid\_header http\_500  
http\_502 http\_503 http\_504;  
proxy\_cache\_valid 60m;  
proxy\_redirect off;  
proxy\_connect\_timeout 120;  
proxy\_send\_timeout 120;  
proxy\_read\_timeout 120;  
proxy\_buffers 8 16k;  
proxy\_buffer\_size 16k;  
proxy\_busy\_buffers\_size 64k;  
proxy\_cache\_key $host$request\_uri;  
proxy\_set\_header X-Forwarded-For $IP;  
proxy\_set\_header Host $VAR\_HOST;  
proxy\_pass $REQUEST\_PROTO://$PROXY\_TO;

Has anyone experienced anything like this before? Or is there any  
setting  
within NGINX that could be the culprit? The server being proxied is  
running  
IIS, but when I run the long running script directly against the proxied  
server, I’m not getting the same behavior. The long running script runs  
and  
I’m able to open a new browser tab and continue browsing as well.

Posted at Nginx Forum:

> **[Proxy returns 504 then blocks next connections](https://forum.nginx.org/read.php?2,240766,240766#msg-240766)**
>
> I'm having an issue where I proxy a long running script and receive a 504 error when it exceeds my proxy\_read\_timeout setting. All of that's behaving normally -- what isn't behaving normally is that the next several requests I make to the domain via...

---

<div class="post-metadata">

**Author:** ![abstein2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@abstein2](https://www.ruby-forum.com/u/abstein2)\
**Post date:** [July 12, 2013, 2:18am UTC](https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739/2 "2013-07-12T02:18:40Z")

</div>

Does your script use sessions? You didn’t specify with language it uses,  
but  
several popular languages such as PHP will lock a session file until the  
request is complete, preventing multiple requests while the first  
request  
continues to run. Mechanisms similar to session\_write\_close() in PHP can  
work around this, but it sounds like this script should run as a  
background  
process rather than as a web request.

Posted at Nginx Forum:

> **[Re: Proxy returns 504 then blocks next connections](https://forum.nginx.org/read.php?2,240766,240771#msg-240771)**
>
> I'm having an issue where I proxy a long running script and receive a 504 error when it exceeds my proxy\_read\_timeout setting. All of that's behaving normally -- what isn't behaving normally is that the next several requests I make to the domain via...

---

<div class="post-metadata">

**Author:** ![abstein2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@abstein2](https://www.ruby-forum.com/u/abstein2)\
**Post date:** [July 15, 2013, 6:47am UTC](https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739/3 "2013-07-15T06:47:11Z")

</div>

The script is an ASPX script and, to my knowledge, it doesn’t use  
sessions.  
I don’t control the script, but I can’t duplicate the behavior when  
running  
against the proxied server. It only occurs when going through the proxy.  
I  
don’t believe sessions are the issue.

Posted at Nginx Forum:

> **[Re: Proxy returns 504 then blocks next connections](https://forum.nginx.org/read.php?2,240766,240842#msg-240842)**
>
> I'm having an issue where I proxy a long running script and receive a 504 error when it exceeds my proxy\_read\_timeout setting. All of that's behaving normally -- what isn't behaving normally is that the next several requests I make to the domain via...

---

<div class="post-metadata">

**Author:** ![abstein2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a3d4f5/32.png) [@abstein2](https://www.ruby-forum.com/u/abstein2)\
**Post date:** [July 15, 2013, 1:05pm UTC](https://www.ruby-forum.com/t/proxy-returns-504-then-blocks-next-connections/245739/4 "2013-07-15T13:05:52Z")

</div>

Hello!

On Mon, Jul 15, 2013 at 12:46:41AM -0400, abstein2 wrote:

> The script is an ASPX script and, to my knowledge, it doesn’t use sessions.  
> I don’t control the script, but I can’t duplicate the behavior when running  
> against the proxied server. It only occurs when going through the proxy. I  
> don’t believe sessions are the issue.

For me it looks like the problem is a concurent connections limit  
in a browser. Not sure why it’s triggered though, but probably  
there are other connections to the same host open.

If you are using Chrome, try looking into  
chrome://net-internals/ page, it might be helpful.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
