memcache_connect() [function.memcache-connect]: Can’t connect to localhost:11211
by Thomas Hambach
Encountered this error? It could be as simple as switching the host from localhost to 127.0.0.1
before:
<?php
$memcache_obj = memcache_connect('localhost', 11211);
after:
<?php
$memcache_obj = memcache_connect('127.0.0.1', 11211);
It works! Thanks a lot
This occured on Windows right? If so then its because localhost isnt resolved to 127.0.0.1 by PHP if localhost is defined to both an IPv4 and IPv6 alias in the host file
Thanks,Kalle..I’ve connected the server by localhost without error..Just modify the the hosts file.
class main extends Memcache{
function main(){
$this->connect(‘localhost’,11211);
}
}
You guys could connect to the server by modifying the host? I need to have a try. But I still feel very puzzle why there is a problem like that.