# Memcache issue

**URL:** <https://www.ruby-forum.com/t/memcache-issue/206604>\
**Category:** NGINX\
**Created:** [May 5, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/memcache-issue/206604 "2011-05-05T17:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 5, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/memcache-issue/206604/1 "2011-05-05T17:52:43Z")

</div>

Hello,  
I am using PHP to connect to memcache.

I connect memcache service in the PHP code as follows:  
$memcache = new Memcache;  
$memcache-\>connect(‘127.0.0.1’, 11211); //connect to memcached server

Then when I connect to NGX server, I got 500 or 502 error.

However, if I run the memcache using php test.php directly, I can  
connect to memcache server successfully.

I am using php-fpm.

Does anyone encounter the similar issue before?

Thanks,  
Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 6:03pm UTC](https://www.ruby-forum.com/t/memcache-issue/206604/2 "2011-05-05T18:03:04Z")

</div>

What is in error\_log ?

–  
Igor S.

05.05.2011, 19:52, “Yanxin Z.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ():

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 6:10pm UTC](https://www.ruby-forum.com/t/memcache-issue/206604/3 "2011-05-05T18:10:27Z")

</div>

Thank you for your help, Igor.

The log is

1815426 2011/05/05 09:05:09 [notice] 13424#0: _15  
"/api/1.0/(._)/upload\_internal" matches “/api/1.0/  
web/upload\_internal”, client: 10.1.4.250, server: localhost, request:  
“POST /api/1.0/web/upload\_internal HTTP/1.1”, host: “10.1.4.243”  
1815427 2011/05/05 09:05:09 [notice] 13424#0: \*15 rewritten data:  
“/api/1.0/web/upload.php”, args: “”, client: 10.1.4.250, server:  
localhost, request: “POST /api/1.0/web/upload\_internal HTTP/1.1”,  
host: “10.1.4.243”  
1815428 2011/05/05 09:05:09 [error] 13424#0: \*15 recv() failed (104:  
Connection reset by peer) while reading response header from upstream,  
client: 10.1.4.250, server: localhost, request: “POST /  
api/1.0/web/upload\_internal HTTP/1.1”, upstream:  
“fastcgi://127.0.0.1:9000”, host: “10.1.4.243”  
1815429 2011/05/05 09:05:09 [info] 13424#0: \*15 client 10.1.4.250 closed  
keepalive connection

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 6:28pm UTC](https://www.ruby-forum.com/t/memcache-issue/206604/4 "2011-05-05T18:28:02Z")

</div>

Hello Igor,  
Thank you for your direction.

I searched for “nginx 104: Connection reset by peer”

In the forum  
[http://forum.slicehost.com/comments.php?DiscussionID=433](http://forum.slicehost.com/comments.php?DiscussionID=433)

Someone suggest to restart fastcgi.

I did restart php-fpm then, memcached is working now.

Hopefully my post is helpful to other members.  
Yanxin
