ktbkea
Last Updated: February 25, 2016
·
24.31K
· 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

9269

Cool! thanks man!

over 1 year ago ·
12941

The correct command should be:

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

Thanks, It was very helpful for me.

over 1 year ago ·
14741

Thank you, It helped me :)

over 1 year ago ·
16145

Many thanks for sharing this critical solution!

over 1 year ago ·
16354

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

over 1 year ago ·
17645

Thank you!

over 1 year ago ·
22157

Thanks! It works!

over 1 year ago ·