I thought a web server process I brought up was listening on localhost:8080, and tried to connect to it, but kept getting connection reset errors. As it turns out, I was mistaken and my process was listening on a totally different port.
What I can't understand, however, is why I was getting the connection reset errors, rather that "connection refused" that you'd normally get if no process was listening on that port. There isn't anything else listening on 8080 as far as I can tell:
$ sudo lsof -i -P | grep 8080 # no result $ sudo netstat -a -n | grep 8080 # still no result
Yet connections to this port are initially accepted (although closed on further data):
$ /usr/local/bin/wget localhost:8080 --2014-01-14 16:29:22-- http://localhost:8080/ Resolving localhost... ::1, 127.0.0.1, fe80::1 Connecting to localhost|::1|:8080... failed: Connection refused. Connecting to localhost|127.0.0.1|:8080... connected. HTTP request sent, awaiting response... No data received.
Similarly with telnet:
$ telnet localhost 8080 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'.
Trying other random ports just results in the expected connection refused error:
$ telnet localhost 8081 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying fe80::1... telnet: connect to address fe80::1: Connection refused telnet: Unable to connect to remote host
My hosts file is bare bones:
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost