I just upgraded from Mavericks to Yosemite, and now curl
can't see loopback host names.
Set up a simple http server to test:
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
Now I can hit localhost:8000 in chrome. I can even wget it. But in curl, this happens:
$ curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
However, this works:
$ curl 127.0.0.1:8000
I read this answer about wget proxy settings, but it didn't help, because this works:
$ wget --proxy=off localhost:8000
This is really frustrating, because I have a few different loopback hostnames listed in my /etc/hosts
file so I can develop apps locally, and I'm used to debugging them with curl.
I've tried with the version of curl that ships with osx:
$ 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
And I've tried compiling curl with brew:
$ /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
Best Answer
I just got it to work by commenting out one of the IPv6 loopback lines from my /etc/hosts file:
Now all of my loopback hostnames work, not just localhost. I wonder what's up with this?