curl resolves all non-SSL URLs to and port 8080

jotadepicas asked:

I’m executing curl and no matter what URL I point it to, it always tries to connect to and port 8080:

$ curl -v http://asdfsafzsdfsdf/
*   Trying
* connect to port 8080 failed: Connection refused
* Failed to connect to localhost port 8080: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 8080: Connection refused

In the above example I’m using a non-existing domain ‘asdfsafzsdfsdf’ but the same happens with existing domains like

But, if I point it to an SSL URL like, it resolves and performs the request OK. Also, if I point it to https://asfasdfasdfdasfd, it tries to resolv it and fails (no weird resolution):

$ curl -v https://asdfsadfsafsdf
* Rebuilt URL to: https://asdfsadfsafsdf/
* Could not resolve host: asdfsadfsafsdf
* Closing connection 0
curl: (6) Could not resolve host: asdfsadfsafsdf

This suggests me that perhaps “some” form of interference cannot happen when making SSL connections (maybe they cannot be cached by whatever it is that is causing this, or something).

If I run “host asdfsadfsadf” or “dig asdfasfsafa” it fails as you would expect it to. But “wget” behaves the same way as “curl” (I know they resolve DNS differently, so maybe this is a clue).

I’ve been investigating this for hours now. I don’t have any entries in /etc/hosts, I’m not running any DNS cache, I’ve checked /etc/nsswitch.conf and I just have “files, dns” resolution, I don’t have any special iptables configurations, etc.

More importantly, putting aside the DNS part of the problem… why port 8080?

This is super weird, why could this be happening? Any ideas?

I’m running Ubuntu 16.04.


My answer:

It looks like you have a proxy server defined in your environment, e.g. in the http_proxy environment variable.

Check your shell environment and remove the variable from whichever shell startup script defines it, or start the proxy server.

Alternately, you can ask curl to ignore the proxy environment variable by passing -x "".

curl -x ""

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.