4

I have install memcached and when I try a script test like this one :

$memcache = new Memcache; $memcache->connect('127.0.0.1', 11211); echo $memcache->getVersion(); 

I recive the nest error :

: Notice: MemcachePool::getversion(): Server 127.0.0.1 (tcp 11211, udp 0) failed with: Network timeout (0) in /var/www/html/admin/test.php on line 62

What could be the problem? I'm new to memcached.

3 Answers 3

5

Verify listening

Run lsof -i as root and confirm that the memcache daemon is running on the port you listed.

Formatted for sanity:

memcached 16526 corneliu 31u IPv4 207975 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 32u IPv6 207976 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 33u IPv4 207979 0t0 UDP *:memcache memcached 16526 corneliu 34u IPv6 207980 0t0 UDP *:memcache 

So the memcache server is listening on both TCP and UDP for both IPv4 and IPv6. I assume that the /etc/services entry for memcache is port 11211. Service is listening.

Manually verify the server responds to commands

I'd reference this question: https://stackoverflow.com/questions/6045187/memcache-connects-but-doesnt-respond-to-any-command and verify that the server is responding to commands that you send via telnet or netcat. It will probably also be very helpful if you run tcpdump or wireshark to capture the network traffic and actually see what packets are traveling.

Debug things without changing the memcache configuration first. Attempting to change the server's bind address per that question above should be the last thing you do. Let me know your progress.

6
  • memcached 16526 corneliu 31u IPv4 207975 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 32u IPv6 207976 0t0 TCP *:memcache (LISTEN) memcached 16526 corneliu 33u IPv4 207979 0t0 UDP *:memcache memcached 16526 corneliu 34u IPv6 207980 0t0 UDP *:memcache Commented Feb 29, 2012 at 13:19
  • anybody, any help ? Commented Feb 29, 2012 at 13:30
  • ok. i try : telnet 127.0.0.1 11211 and i recive "..command not found"; next i try : memcached -B binary and i recive "faild to listen....address already in use" ; finaly i try like in the link to put de ip of the site and i recive ( in browser ) this error : Warning: Memcache::connect(): Can't connect to 192.99.141.133:11211 Commented Feb 29, 2012 at 15:03
  • You need to install a functioning client of some kind... netcat or telnet, and use one of them for the first test. The second operation of server parameters changing is supposed to be used for configuring your running instance, not executed on top of it. It is probably the case that you don't yet have the necessary debugging skills required to complete this exercise. Namely, you should recognize that installing a telnet client or netcat is appropriate instead of telling me "command not found." You may want to hire a consultant if you're in a situation with enough load to need memcache. Commented Feb 29, 2012 at 15:09
  • Sounds like memcached (or something) is running and listening on port 11211, have you checked your firewall settings? Commented Feb 29, 2012 at 15:56
4

many people had good results with using pconnect instead of connect

$memcache = new Memcache; $memcache->pconnect('127.0.0.1', 11211); echo $memcache->getVersion(); 

more info here http://hostingfu.com/article/memcachepoolget-server-failed-with-network-timeout-possible-fixes

2
  • This is only a workaround; it doesn't solve the actual problem, and neither you nor the person you linked to explain what this does or why it's useful. Commented Dec 4, 2012 at 17:02
  • sorry for that ... i just wanted to share what i experienced was working for me.. here is some more information about pconnect... php.net/manual/en/memcache.pconnect.php Commented Dec 5, 2012 at 8:27
-1

Just start the memcache Daemon by using this command in terminal

memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody 

where

  • -m for memory ,
  • -p for port ,
  • -l for ip address of server ,
  • -u for user

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.