Saturday, April 30, 2011

/etc/hosts file messed up on Snow Leopard

Whenever I run a Rails app, I had to access it via http://0.0.0:port_number. Devise Rails plugin sample app barks when redirecting with this error message:

ERROR URI::InvalidURIError: the scheme http does not accept registry part: 0.0.0:3000 (or bad hostname?)

1) To cleanup the mess, I edited the /etc/hosts file so it now looks like this:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
## localhost broadcasthost
::1 localhost
fe80::1%lo0 localhost

2) Then flush the cache to pickup the new changes by running :

sudo dscacheutil -flushcache

Now you can access your local Rails apps by : http://localhost:port_number and Devise is happy again.