Last Updated: February 25, 2016
·
28.3K
· junior-ales

Play Framework 2 error: "nodename nor servname provided, or not known"

Then there was me fiddling with play framework... and in the first time I ran the sample application a beautiful stack trace with this exception poped up:

Caused by: java.net.UnknownHostException: [HOSTNAME_NAME]: nodename nor servname provided, or not known

After some research I found out that the issue is a bug in JDK 7 for OSX. It seems it doesn't recognize your hostname as localhost, so the workaround is pretty easy:

Add in your hosts file your hostname pointing to 127.0.0.1

$ sudo echo "127.0.0.1 [YOUR_HOSTNAME]" >> /etc/hosts

Important: do not delete your "127.0.0.1 localhost" entry in /etc/hosts because it's used to configure the loopback interface when the system is booting

source: http://bit.ly/1a9B5it

8 Responses
Add your response

Cool! thanks man!

over 1 year ago ·

The correct command should be:

$ echo "127.0.0.1 $HOSTNAME" | sudo tee -a /etc/hosts
over 1 year ago ·

Thanks, It was very helpful for me.

over 1 year ago ·

Thank you, It helped me :)

over 1 year ago ·

Many thanks for sharing this critical solution!

over 1 year ago ·

Thank you so much. It is nice to have this be such a highly published result on google.

over 1 year ago ·

Thank you!

over 1 year ago ·

Thanks! It works!

over 1 year ago ·