我以为我启动的 Web 服务器进程正在监听 localhost:8080,并尝试连接它,但一直收到连接重置错误。事实证明,我搞错了,我的进程正在监听一个完全不同的端口。
但是,我不明白的是,为什么我会收到连接重置错误,而不是在没有进程监听该端口时通常会收到的“连接被拒绝”错误。据我所知,8080 上没有任何其他东西在监听:
$ sudo lsof -i -P | grep 8080
# no result
$ sudo netstat -a -n | grep 8080
# still no result
然而,到该端口的连接最初是被接受的(尽管不再接受进一步的数据):
$ /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.
与 telnet 类似:
$ telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
尝试其他随机端口只会导致预期的连接被拒绝错误:
$ 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
我的主机文件非常简单:
##
# 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
答案1
不确定为什么删除了评论,但问题出在 Cisco AnyConnect 安全移动客户端上。
另一个线程这个答案。这看起来是 Cisco AnyConnect 安全移动客户端的一个问题。