Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The --help output for curl lists a --resolve option, which states

--resolve <host:port:address> Force resolve of HOST:PORT to ADDRESS

I'm not having any luck getting it to work though. The basic command I'm trying to run is

curl --resolve foo.example.com:443:localhost https://foo.example.com:443/

and I keep getting the response Couldn't resolve host 'foo.example.com'. I want do do this because I'm testing a certificate for foo.example.com, but I'm not testing it on the actual server. Instead, I'm testing it on a dummy machine. I know that I can edit /etc/hosts so that foo.example.com resolves to localhost, but this curl approach seems like it would be the "correct" way to go, if I could make it work.

Does anybody see what I'm doing wrong here?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

It appears that the address needs to be a numeric IP address, not a hostname.

Try this:

curl --resolve foo.example.com:443: https://foo.example.com:443/
share|improve this answer
And that solves it. Thank you very much! –  tsuraan Mar 1 '12 at 1:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.