Aliasing Loopback on OSX

aka…how to make it possible to use 127.0.0.2, 127.0.0.3, … on your Mac.

This post comes from a need I had to start cassandra in multiple instances on a single Mac (testing a cluster configuration out), and failing to do so. Previously on Linux, I had configured multiple instances to bind to 127.0.0.1 and 127.0.0.2 and it worked without any trouble. On the Mac though, I got the exception:

java.net.BindException: Can't assign requested address
	at sun.nio.ch.Net.bind(Native Method)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
	at org.apache.cassandra.net.MessagingService.listen(MessagingService.java:138)
	at org.apache.cassandra.service.StorageService.initServer(StorageService.java:319)
	at org.apache.cassandra.thrift.CassandraDaemon.setup(CassandraDaemon.java:99)
	at org.apache.cassandra.thrift.CassandraDaemon.main(CassandraDaemon.java:177)

Until Jonathan Ellis and Peter Schuller on the cassandra list told me I could alias the extra addresses to loopback using this:

sudo ifconfig lo0 add 127.0.0.2

After that, ifconfig shows the added IP under the “lo0″ device and cassandra can connect to it.

July 26, 2010 В· polesen В· No Comments
Tags: , ,  В· Posted in: Operating Systems

Leave a Reply