Adi Adi - 1 year ago 214
Linux Question

ping: unknown host localhost:8090

I am stuck on this from last many hours and did a lot of research.

I used multiple servers for the same code (AWS and DigitalOcean Linux).

I am running a Golang Web Server on port 8090.

err := http.ListenAndServe("", nil)

It shows that it is running (in the attached image) at port 8090 but when I run:

ping http://localhost:8090



Both shows me same error:

ping: unknown host

Any suggestions would be welcome.


Answer Source

The classic ping does not work for testing TCP ports, just hosts (see I've seen many frameworks provide a "ping" option to test if the server is alive, may be this is the source of the mistake.

I like to use netcat:

$ nc localhost 8090 -vvv
nc: connectx to localhost port 8090 (tcp) failed: Connection refused

$ nc localhost 8888 -vvv
found 0 associations
found 1 connections:
     1: flags=82<CONNECTED,PREFERRED>
     outif lo0
     src ::1 port 64550
     dst ::1 port 8888
     rank info not available
     TCP aux info available

Connection to localhost port 8888 [tcp/ddi-tcp-1] succeeded!

You may have to install it with sudo yum install netcat or sudo apt-get install netcat (respectively for RPM and DEB based distros).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download