# Connection reset by peer and other problems

**URL:** <https://www.ruby-forum.com/t/connection-reset-by-peer-and-other-problems/235595>\
**Category:** NGINX\
**Created:** [July 2, 2013, 1:26pm UTC](https://www.ruby-forum.com/t/connection-reset-by-peer-and-other-problems/235595 "2013-07-02T13:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [July 2, 2013, 1:26pm UTC](https://www.ruby-forum.com/t/connection-reset-by-peer-and-other-problems/235595/1 "2013-07-02T13:26:54Z")

</div>

Hi guys,

I’m getting a lot of errors on logs right now and we’ve already tried  
everything to solve the problem without success.  
Everything was running just fine until last week.

We use nginx and php-fpm.  
nginx version: nginx/1.2.0

The errors that we getting are from random pages and random domains this  
is  
not specific.

Here is some errors from the logs:

[error] 26002#0: _8882 readv() failed (104: Connection reset by peer)  
while  
reading upstream, client: XX.XXX.XX.XXX, server: www.DOMAINX._, request:  
“GET / HTTP/1.1”, upstream:  
“fastcgi://unix:/var/run/php5-fpm/site\_live.sock:”, host: “[DOMAINX.de](http://DOMAINX.de)”,  
referrer:  
“[Redirect Notice](http://www.google.de/url?sa=t&rct=j&q=DOMAINX&source=web&cd=1&sqi=2&ved=0CDsQFjAA&url=https%3A%2F%2FDOMAINX.de%2F&ei=EaDSUd7UK6K84ASlu4DABA&usg=AFQjCNEd-czvmCp5Jji3kkpWZ1MtMdhpMA&bvm=bv.48572450,d.bGE)”

[error] 26002#0: _8879 recv() failed (104: Connection reset by peer)  
while  
reading response header from upstream, client: XX.XX.X.XX, server:  
www.DOMAINX._, request: “GET /files/2013/06/Twitter1.png HTTP/1.1”,  
upstream: “fastcgi://unix:/var/run/php5-fpm/site\_live.sock:”, host:  
“DOMAINX.nl”

[error] 26016#0: _6433 FastCGI sent in stderr: “Primary script unknown”  
while reading response header from upstream, client: 80.153.156.134,  
server:  
www.DOMAINX._, request: “GET  
/bezgotowkowo/conversion.php?campaignID=11759&productID=17653&conversionType=sale&descrMerchant=&descrAffiliate=&gtmcb=1675309277  
HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm/site\_live.sock:”,  
host: “DOMAINX.pl”, referrer: “[https://DOMAINX.at/order-skip](https://DOMAINX.at/order-skip)”

## And here is is our nginx configs:

server {  
listen 95;  
server\_name www.DOMAINX.th DOMAINX.th www.DOMAINX.se DOMAINX.se  
www.DOMAINX.be DOMAINX.be;  
rewrite ^ $scheme://DOMAINX.de$request\_uri?;  
}

server {  
listen 95;  
server\_name [www.DOMAINX.com](http://www.DOMAINX.com);  
rewrite ^ $scheme://DOMAINX.com$request\_uri?;  
}

server {  
listen 95;  
server\_name [DOMAINX.com](http://DOMAINX.com);

access\_log /site/logs/live/nginx/landing.access.log main;  
error\_log /site/logs/live/nginx/landing.error.log;  
root /site/www/htdocs/landing.live/public/;  
index index.html index.php;

port\_in\_redirect off;

if ($http\_x\_forwarded\_protocol !~\* ‘https’) {  
return 301 https://$host$request\_uri;  
}

error\_page 404 /redirect;  
rewrite ^/redirect $scheme://$host;

location ~ .php$ {  
fastcgi\_pass unix:/var/run/php5-fpm/site\_live.sock;  
fastcgi\_index index.php;  
include fastcgi\_params;

```
fastcgi_param PHP_VALUE "max_input_time=1200\n

```

memory\_limit=512M\n post\_max\_size=128M\n upload\_max\_filesize=128M\n  
newrelic.enabled=1\n [newrelic.appname=DOMAINX.com](http://newrelic.appname=DOMAINX.com)\n  
newrelic.framework=zend\n  
error\_log=/site/logs/live/nginx/site.error.log";  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
fastcgi\_param APPLICATION\_ENV live;  
fastcgi\_param HTTPS $thttps;  
}  
}

server {  
listen 95;  
server\_name m.DOMAINX.\*;

access\_log /site/logs/live/nginx/mobile.access.log main;  
error\_log /site/logs/live/nginx/mobile.error.log;  
root /site/www/htdocs/mobile.live/public/;  
index index.html index.php;

port\_in\_redirect off;

location ~ .php$ {  
fastcgi\_pass unix:/var/run/php5-fpm/site\_live.sock;  
fastcgi\_index index.php;  
include fastcgi\_params;

```
fastcgi_param PHP_VALUE "max_input_time=1200\n

```

memory\_limit=512M\n post\_max\_size=128M\n upload\_max\_filesize=128M\n  
newrelic.enabled=1\n newrelic.appname=mobile-live\n  
newrelic.framework=zend\n  
error\_log=/site/logs/live/nginx/site.error.log";  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
fastcgi\_param APPLICATION\_ENV live;  
fastcgi\_param HTTPS $thttps;  
}

error\_page 401 /error/401.html;  
error\_page 403 /error/403.html;  
error\_page 404 /error/404.html;  
error\_page 500 502 503 504 /error/50x.html;

location /error {  
root /var/www/default/;  
}  
}

server {  
listen 95;  
server\_name [developer.DOMAINX.com](http://developer.DOMAINX.com);

access\_log /data/site/logs/live/nginx/landing.developer.access.log  
main;  
error\_log /data/site/logs/live/nginx/landing.developer.error.log;

root /var/www/developer;  
index index.html index.php;

location ~ .php$ {  
fastcgi\_pass unix:/var/run/php5-fpm/developer.sock;  
fastcgi\_index index.php;  
include fastcgi\_params;

```
fastcgi_param PHP_VALUE "max_input_time=1200\n

```

memory\_limit=512M\n post\_max\_size=128M\n upload\_max\_filesize=128M\n  
newrelic.enabled=1\n newrelic.appname=developer\n  
error\_log=/data/site/logs/live/developer.error.log";  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
fastcgi\_param APPLICATION\_ENV live;  
fastcgi\_param HTTPS $thttps;  
}

error\_page 401 /error/401.html;  
error\_page 403 /error/403.html;  
error\_page 404 /error/404.html;  
error\_page 500 502 503 504 /error/50x.html;

location /error {  
root /var/www/default/;  
}

}

server {  
listen 95 default\_server;  
server\_name www.DOMAINX.\* DOMAINX.\* site.DOMAINX.\*;

access\_log /site/logs/live/nginx/site.access.log main;  
error\_log /site/logs/live/nginx/site.error.log;

client\_max\_body\_size 20m;  
client\_header\_timeout 1200;  
client\_body\_timeout 1200;  
send\_timeout 1200;  
keepalive\_timeout 1200;

set $thttps $https;  
set $tscheme $scheme;  
if ($http\_x\_forwarded\_protocol = https) {  
set $thttps on;  
set $tscheme “https”;  
}  
if ($http\_x\_forwarded\_protocol = HTTPS) {  
set $thttps on;  
set $tscheme “https”;  
}

root /site/www/htdocs/site.live/site/public/;  
try\_files $uri $uri/ /index.php?$args;  
index index.php;

location ^~ /files/ {  
expires 864000;  
fastcgi\_pass unix:/var/run/php5-fpm/site\_live.sock;  
fastcgi\_index index.php;  
include fastcgi\_params;

```
fastcgi_connect_timeout 1200;
fastcgi_send_timeout 1200;
fastcgi_read_timeout 1200;

fastcgi_param PHP_VALUE "max_input_time=1200\n

```

memory\_limit=512M\n post\_max\_size=128M\n upload\_max\_filesize=128M\n  
newrelic.enabled=1\n newrelic.appname=site-live\n  
newrelic.framework=zend\n  
error\_log=/site/logs/live/nginx/site.error.log";  
fastcgi\_param SCRIPT\_FILENAME  
/site/www/htdocs/site.live/site/public/index.php$args;  
fastcgi\_param APPLICATION\_ENV live;  
fastcgi\_param HTTPS $thttps;  
# allow clients to cache served resources  
fastcgi\_param PHP\_ADMIN\_VALUE “session.cache\_limiter = public”;  
}

location ~ .php$ {  
fastcgi\_pass unix:/var/run/php5-fpm/site\_live.sock;  
fastcgi\_index index.php;  
include fastcgi\_params;

```
fastcgi_connect_timeout 1200;
fastcgi_send_timeout 1200;
fastcgi_read_timeout 1200;

fastcgi_param PHP_VALUE "max_input_time=1200\n

```

memory\_limit=512M\n post\_max\_size=128M\n upload\_max\_filesize=128M\n  
newrelic.enabled=1\n newrelic.appname=site-live\n  
newrelic.framework=zend\n  
error\_log=/site/logs/live/nginx/site.error.log";  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
fastcgi\_param APPLICATION\_ENV live;  
fastcgi\_param HTTPS $thttps;  
# emulate ‘session.cache\_limiter = nocache’ setting in “php.ini”:  
fastcgi\_param PHP\_ADMIN\_VALUE “session.cache\_limiter = nocache”;  
}

error\_page 401 /error/401.html;  
error\_page 403 /error/403.html;  
error\_page 404 /error/404.html;  
error\_page 500 502 503 504 /error/50x.html;

location /error {  
root /var/www/default/;  
}

location /rev.txt {  
access\_log off;  
auth\_basic off;  
}

set $redirect off;  
if ($host ~\* "DOMAINX.(._)") {  
set $tld $1;  
}  
if ($host ~_ "^www.DOMAINX.(._)") {  
set $redirect on;  
}  
if ($host ~_ "(zenpay|evopay).(._)") {  
set $tld $2;  
rewrite ^ $scheme://DOMAINX.$tld$request\_uri? permanent;  
}  
if ($request\_uri ~_ rev.txt) {  
set $redirect off;  
}

if ($thttps != “on”) {  
set $redirect on;  
}  
if ($redirect = on) {  
rewrite ^ https://DOMAINX.$tld$request\_uri? permanent;  
}

if (-f /var/deploy/live.maintenance.lock) {  
rewrite ^(.\*)$ /maintenance.php break;  
}

}

Thanks for your help.

Posted at Nginx Forum:

> **[Connection reset by peer and other problems](https://forum.nginx.org/read.php?2,240477,240477#msg-240477)**
>
> Hi guys, I'm getting a lot of errors on logs right now and we've already tried everything to solve the problem without success. Everything was running just fine until last week. We use nginx and php-fpm. nginx version: nginx/1.2.0 The errors

---

<div class="post-metadata">

**Author:** ![hawkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/278dde/32.png) [@hawkins](https://www.ruby-forum.com/u/hawkins)\
**Post date:** [July 11, 2013, 4:28pm UTC](https://www.ruby-forum.com/t/connection-reset-by-peer-and-other-problems/235595/2 "2013-07-11T16:28:39Z")

</div>

This was solved.

The problem was related with New Relic module.  
2 weeks to find the problem. ☹

Posted at Nginx Forum:

> **[Re: Connection reset by peer and other problems](https://forum.nginx.org/read.php?2,240477,240758#msg-240758)**
>
> Hi guys, I'm getting a lot of errors on logs right now and we've already tried everything to solve the problem without success. Everything was running just fine until last week. We use nginx and php-fpm. nginx version: nginx/1.2.0 The errors

---

<div class="post-metadata">

**Author:** ![hawkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/278dde/32.png) [@hawkins](https://www.ruby-forum.com/u/hawkins)\
**Post date:** [January 12, 2014, 2:58pm UTC](https://www.ruby-forum.com/t/connection-reset-by-peer-and-other-problems/235595/3 "2014-01-12T14:58:19Z")

</div>

Could you tell us how did you fix this problem?

Posted at Nginx Forum:

> **[Re: Connection reset by peer and other problems](https://forum.nginx.org/read.php?2,240477,246289#msg-246289)**
>
> Hi guys, I'm getting a lot of errors on logs right now and we've already tried everything to solve the problem without success. Everything was running just fine until last week. We use nginx and php-fpm. nginx version: nginx/1.2.0 The errors
