Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 127.0.0.1 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

share|improve this question
    
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
add comment

3 Answers

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.
-l 127.0.0.1

Change that to

-l 0.0.0.0

and restart memcached.

share|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 127.0.0.1:11211 or 0.0.0.0:11211. –  Majenko Jun 1 '11 at 12:07
    
the output is 0.0.0.0:* –  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
add comment

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
share|improve this answer
add comment

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.
share|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
add comment

Your Answer

 
discard

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.