I just installed memcached on my Mac OS X 10.6.8. It installed perfectly and when I type in memcached
in Terminal I get this:
failed to listen on TCP port 11211 tcp
listen: Address already in use
And I have a script in my localhost that contains this:
$memcache = new Memcache();
But I get an error thrown saying Fatal error: Class 'Memcache' not found
.
How can I get memcached to work, is it because the port 11211 is not listened to which probably doesn't make memcached work?
Your first error is probably because memcached is already running. If you run
ps -e | grep memcache | grep -v grep
you'll probably see it. The output ofnetstat -a -p tcp | grep LISTEN
will show you all the listening services too, which may help.The second issue is probably because you don't have a memcache extension installed for your version of PHP (from the error I'm assuming you're using PHP). You probably want http://pecl.php.net/package/memcache to solve that.
Memcache could already be running. I had a crashed version of memcache running and got this problem.
I found this helpful:
Once I had the pid I killed memcache
I then edited the config
I added
I also ran into the first error you reported:
In my configuration I found the error was caused by multiple
-l
arguments to the same address. On Ubuntu my/etc/memcached.conf
file contained:memcached was able to successfully bind to the first address, but because
127.0.0.1
duplicateslocalhost
, memcached gave theAddress already in use
error when it tried to bind to the second address.If you're running into this error and can't find an existing process binding to your port, double-check your memcached configuration. If you're listening for connections on multiple addresses, ensure those addresses don't represent the same address. Such a setup could cause this error.