有一个nginx服务器监听8080端口,并通过本地主机和127.0.0.1进行telnet。如果连接成功,则一个连接成功,否则一个连接失败。
[test@localhost sbin]$ telnet localhost 8080
Trying ::1...
telnet: connect to address ::1: Connection refused
[test@localhost sbin]$ telnet 127.0.0.1 8080
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
“localhost”和“127.0.0.1”有什么区别?为什么连接“localhost”失败?谢谢!