I'm running a Rails app locally (Thin server), and I can connect locally from the browser (localhost:3000), but when I try to use curl, I get:
curl -H 'id:1' -i 'http://localhost:3000/api/data' -v
* Hostname was NOT found in DNS cache
* Trying ::1...
* Adding handle: conn: 0x7fd121808200
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fd121808200) send_pipe: 1, recv_pipe: 0
* Connection failed
* connect to ::1 port 3000 failed: Connection refused
* Trying fe80::1...
* Connection failed
* connect to fe80::1 port 3000 failed: Connection refused
* Failed to connect to localhost port 3000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 3000: Connection refused
This used to work just fine, but I recently updated to Mavericks, which I suspect may have broken something. I can also curl successfully from the web.
http://127.0.0.1:3000/api/data
? Looks like for some reason curl goes straight to ipv6... – Solingen127.0.0.1 localhost
to link the name localhost to the loopback address 127.0.0.1. If that line is there, there may be a problem with resolv.conf or whatever confirguration file a mac uses to decide whether to consult the hostsfile and/or dns, and the order in which it does. – Solingendscacheutil -flushcache
could be what you need to do (assuming /etc/hosts is OK) – Solingen