Take the 2-minute tour ×

From resourses in Internet, the usage of php memcache is like that.

$memcache= new Memcache;
$memcache->connect('', 11211);

But I think of one query.
What if we put the first argument with host other than localhost?
Does it mean, when I know one's server IP, then I can access its memcache using this function?

It may be because I misunderstand memcache.

Hope someone can understand my query!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Memcached is a daemon that listens particular port (11211 by default) and any number of clients may connect it from any machine (according to firewall rules, if any)

So, yes, if you install memcached to another server you may connect it remotely.


Yes, if there is no any sort of firewalls on the target server and if memcached is set up to listen outer network interface - you could do that.

share|improve this answer
Is there a way to use authentication with memcache though? (I think that's what he is asking) –  John V. Mar 2 '12 at 1:52
@zerkms I believe he is worried about others connecting to his memcached daemon. –  John V. Mar 2 '12 at 1:55
@user988988: if your memcached listens outer network interface and you have no firewall configured - then yes –  zerkms Mar 2 '12 at 1:56
@user988988: is a virtual network interface. It always refers to the local machine. It is accessible only locally. While (ip of this site) for example could be another interface, that is accessible from outside. When any network daemon starts - it binds to one or many interfaces. And depends on that it is either accessible from outside or not. –  zerkms Mar 2 '12 at 2:04
@user988988: code.google.com/p/memcached/wiki/… --- here is an official documentation that explains that –  zerkms Mar 2 '12 at 2:06
show 8 more comments

Your Answer


