Memcached problems “failed to listen on TCP port 11211”

memcached

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?

Best Answer

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 of netstat -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.