Monday, June 21, 2010

EAFNOSUPPORT socket connection issue on Mac OS X

A frustrating problem cropped up this afternoon while trying to get a home-grown Ruby RabbitMQ client to talk to the broker on a MacBook.

The client is based on the EventMachine and AMQP gems, and although for once it worked perfectly on Windows -

(.... yes, frame that last sentence for posterity folks....)

- it was giving bizarre EAFNOSUPPORT socket errors on Mac.

It turns out that, for various obscure reasons, resolving "localhost" is not entirely straightforward on the Mac. There are two quick-and-easy ways round it:

  1. If you have IPv6 mappings for localhost in your /etc/hosts file, comment them out
  2. Replace "localhost" in your connection params with the explicit "127.0.0.1" instead


Sorted!

No comments: