I'm trying to use memcached from a different machine (which has access to my server), but I can't figure out how.

on the memcached machine I can test the connection by running

telnet port

And it works, but on the other machine it just keeps trying to connect

telnet machine_address port
Trying machine_address...

I'm not sure if I should set up something else to get it working. I know the port is working and accessible because if I try to run other services on it, they works.

Os is ubuntu

  • I am having this same problem with my virtual machines, telnet returns "connection refused". Local telnet in the memcache machine does work. Added an explicit rule to the iptables to allow the 11211 port, no dice, added a rule in the router to allow the port, no dice... – Purefan Oct 8 '11 at 15:55

In /etc/memcached.conf:

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.

Change that to


and restart memcached.

| improve this answer | |
  • That didn't work unfortunately. – Oscar Del Ben Jun 1 '11 at 8:52
  • 1
    Check the output of netstat -ln4t then to see if it's listening on or – Majenko Jun 1 '11 at 12:07
  • the output is* – Oscar Del Ben Jun 1 '11 at 14:01
  • Its embarrassing how long it took me to figure this out. Thanks @Majenko – Ascherer Oct 23 '13 at 1:19
  • @Majenko You are talking about Local Address? – chanchal118 Dec 15 '16 at 11:20

Edit the -l line in /etc/memcached.conf. This is where your startup options are stored.

The following line will allow memcached to listen on all interfaces:

sudo sed 's/-l/#-l/' /etc/memcached.conf && sudo service memcached restart
| improve this answer | |

There are two basic possibilities:

  • You've set your memcached instance to listen only on local loopback interface -- you can check this in netstat -l output.
  • You've got your iptables firewall set to reject all incoming connections, except those that are explicitly allowed.
| improve this answer | |
  • I see the port allowed on both nestat and iptables. In ip tables it reads tcp dpt:11211 – Oscar Del Ben Jun 1 '11 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.