I wrote a simple http server in Go language as below:
http.ListenAndServe(":8888", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello"))
}))
When I test it on certain machine runs Windows 7, I found client can't connect to the server.
telnet 127.0.0.1 8888
connecting 127.0.0.1… can't open connection to the host. on port 8888: connect failed. (I translate it from Chinese.)
Then I got the results of other test case:
Anyone can tell me what's going on?
If XAMPP
is running in your machine, the local server sometimes uses 127.0.0.1
as the default. This could be the reason that ping localhost
is working but telnet is not.
Otherwise check other network services or localservers you have running for any conflicts.
Cheers!