Search code examples
macosmemcachedinstances

Memcached on Mac OSX fails when daemonizing second instance


i want to run memcache deamons on my local mac osx (latest os( machine for developing. when i start the first instance like:

sudo memcached -m 8mb -l localhost -p 11211 -d -vv

everything seems to be ok. if i make a lsof on the port this is how it looks like:

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
memcached 614 root    4u  IPv4 0xffffff80113eeda8      0t0  TCP adobe-dns.adobe.com:11211 (LISTEN)
memcached 614 root    5u  IPv6 0xffffff800c5c97b0      0t0  TCP localhost:11211 (LISTEN)
memcached 614 root    6u  IPv6 0xffffff800c5c94a0      0t0  TCP localhost:11211 (LISTEN)
memcached 614 root    7u  IPv4 0xffffff800c3b02c0      0t0  UDP adobe-dns.adobe.com:11211
memcached 614 root    8u  IPv6 0xffffff800c3af140      0t0  UDP localhost:11211
memcached 614 root    9u  IPv6 0xffffff800c3afa00      0t0  UDP localhost:11211

i find this quite strange ... and if i try the second instance on a new port like:

sudo memcached -m 8mb -l localhost -p 11212 -d -vv

i get an error saying:

failed to listen on UDP port 11211 udp listen: Address already in use

even though im starting the daemon on port 11212. can somebody explain or give any hints what this means - what is happening there

THX

Frank


Solution

  • You need to add -U 0 unless you care about UDP support, in which case you'd want to add -U 11212. We straightened this out a bit more in later versions so it does something more intuitive.