3
votes

I'm running memcached, but can't connect. How should I start to debug this? Something appears to be stopping me connecting.

ps -elf | grep memcached 0 S lee 10744 529 0 80 0 - 30529 ep_pol 03:36 pts/22 00:00:00 /usr/bin/memcached -m 512 -p 11211 -u nobody -l 127.0.0.1

(Memcached is definitely running)

But when I try to telnet in, I get a timeout.

telnet 127.0.0.1 11211 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection timed out

Any advice would be appreciated.

2
Your firewall is running? - Andy Triggs

2 Answers

2
votes

Ensure that the local loopback network interface is running. It sounds like you're using a Unix system, so I would recommend running /sbin/ifconfig to see if a section labeled lo with the IP address (labeled as the inet addr) 127.0.0.1 is up and running. If not, run ifdown lo then ifup lo, this should get it going. Read your /etc/hosts file to make sure that localhost or you machine's name is bound to 127.0.0.1. And if your machine is using ipchains or iptables, ensure that those are configured to let traffic pass to 127.0.0.1 from 127.0.0.1.

These things are all fine 99% of the time, but being unable to connect to localhost is indeed odd, so a sanity check is in order.

0
votes

Make sure you don't have any firewall enabled. In my case I found following entries for iptables:

target     prot opt source                destination
ACCEPT     tcp  --  example.com.internal  anywhere             tcp dpt:11211
ACCEPT     udp  --  example.com.internal  anywhere             udp dpt:11211
DROP       tcp  --  anywhere              anywhere             tcp dpt:11211
DROP       udp  --  anywhere              anywhere             udp dpt:11211

They allow connection only from the example.com.internal and deny from anywhere else, including localhost. To fix that I added specific rule for localhost:

ACCEPT     tcp  --  localhost             anywhere             tcp dpt:11211
ACCEPT     udp  --  localhost             anywhere             udp dpt:11211