Address family not supported by protocol family

jaycode picture jaycode · Dec 5, 2010 · Viewed 7.7k times · Source

I tried to do the ruby example shown in this page: http://tomayko.com/writings/unicorn-is-unix

but all I got was

echo.rb:9:in `bind': Address family not supported by protocol family - bind(2) (Errno::EAFNOSUPPORT)
    from echo.rb:9:in `<main>'

Any idea?

Answer

Kevin picture Kevin · Apr 24, 2011

I've encountered the same problem. Just change the localhost to 0.0.0.0:

address = Socket.pack_sockaddr_in(4242, '0.0.0.0')

It seems to appear on Mac only.