我刚刚从Mavericks升级到Yosemite,现在curl
看不到回送主机名。
设置一个简单的http服务器进行测试:
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
现在,我可以在Chrome中访问localhost:8000。我什至可以得到它。但是在卷曲中,会发生这种情况:
$ curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
但是,这可行:
$ curl 127.0.0.1:8000
我阅读了有关wget代理设置的答案,但没有帮助,因为它可以正常工作:
$ wget --proxy=off localhost:8000
这确实令人沮丧,因为我的/etc/hosts
文件中列出了一些不同的回送主机名,因此我可以在本地开发应用程序,并且习惯于使用curl调试它们。
我试过了osx附带的curl版本:
$ curl --version
curl 7.37.1 (x86_64-apple-darwin14.0) libcurl/7.37.1 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz
$ curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
$ curl 127.0.0.1 # works
我尝试用brew编译curl:
$ /usr/local/Cellar/curl/7.38.0/bin/curl --version
curl 7.38.0 (x86_64-apple-darwin14.0.0) libcurl/7.38.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz
$ /usr/local/Cellar/curl/7.38.0/bin/curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
$ /usr/local/Cellar/curl/7.38.0/bin/curl 127.0.0.1:8000 # works