Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

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

share|improve this answer
    
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. –  Michael Hampton Dec 4 '12 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 –  Mik Dec 5 '12 at 8:27
add comment

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: http://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.

share|improve this answer
    
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 –  bejan corneliu Feb 29 '12 at 13:19
    
anybody, any help ? –  bejan corneliu Feb 29 '12 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 –  bejan corneliu Feb 29 '12 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. –  Jeff Ferland Feb 29 '12 at 15:09
    
Sounds like memcached (or something) is running and listening on port 11211, have you checked your firewall settings? –  symcbean Feb 29 '12 at 15:56
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.