Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to 'Memcache' but I've installed it and I think its' running, so far have I done the following correct?

mkdir memcache
tar -xvfz memcache-3.0.6.tgz
cd memcache-3.0.6
make install
echo "" >> /usr/local/lib/php.ini
service httpd restart

However when I try and connect using:

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

I'm provided with: Memcache::connect() [memcache.connect]: Can't connect to localhost:11211, Connection refused (111)

I've seen people say try and telnet using telnet localhost 11211 but if I try that I get Connection Refused

I've tried replacing localhost with but no luck either.

Have I installed the wrong memcache? If so how can I remove the one I have just added? or is that I needed libevent?

share|improve this question
Dumb question, but is the memcached daemon running? Try running a netstat -lntp and looking for 11211. You can also run ps -axw | grep [m]emcached, if you get nothing you need to start the memcached daemon. – d34dh0r53 Jan 17 '12 at 0:07
@d34dh0r53 no it's not there, but when I type memcached I just get command not found – Dan Jan 17 '12 at 0:18

I'm putting this in an answer now as I think I know your problem. You have only installed the PECL module for memcached which is essentially a client library and not the actual memcache server. You need to download and install the latest memcached daemon from here:

Once you have that installed you'll be able to start the daemon and connect to port 11211. As an aside, depending on the distribution you're running there may be a memcached package available to you in your repositories. I would highly recommend you install this package instead of rolling your own memcached as it will greatly simplify upgrading and managing memcached.

share|improve this answer
thanks, do I need to remove what I installed previously? – Dan Jan 17 '12 at 0:36
No, once you have the daemon installed you will use the PECL module to connect to it via PHP. – d34dh0r53 Jan 17 '12 at 17:11

Your Answer


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.