memcache_connect() [function.memcache-connect]: Can’t connect to localhost:11211

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);

5 thoughts on “memcache_connect() [function.memcache-connect]: Can’t connect to localhost:11211

  1. Kalle

    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 ;-)

  2. Jason

    Thanks,Kalle..I’ve connected the server by localhost without error..Just modify the the hosts file.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>