IntelliJ, can't start simple web application: Unable to ping server at localhost:1099

Popcorn picture Popcorn · Sep 28, 2013 · Viewed 102.2k times · Source

I'm trying to make a simple web app in IntelliJ by following this tutorial: http://wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12

I believe my Tomcat is installed correctly since I see the tomcat pictures when I go to http://localhost:8080/

I've followed all the steps up until the part it tells me to run index.jsp, at which point I get the error:

Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: nodename nor servname provided, or not known

I see this in the log:

Application Server was not connected before run configuration stop, reason:
           Unable to ping server at localhost:1099

This 1099 comes from the JMX port in Run -> Edit Configurations.

How do I fix this?

Answer

bond picture bond · Jan 7, 2014

To fix this you need add your machine name in the /etc/hosts file to point to localhost(127.0.0.1).

You can find your machine name by running the following command:

$ hostname
macbook-pro

From the output above you know your hostname is "macbook-pro". Edit "/etc/hosts" file and add that name at the end of line that lists 127.0.0.1

127.0.0.1 localhost macbook-pro

Save the file.

Now you IntelliJ should be able to start your server.