How can I use curl with ::1 for ipv6 based loopback?
Looking at the suggestions — and breakdown of common errors — on this blog post, perhaps you should try this.
curl -g -6 "http://[::1]:8080/"
The -g
seems to be the magical key to get this working. As explained on the curl
man page:
This option switches off the "URL globbing parser". When you set this option, you can specify URLs that contain the letters {}[] without having them being interpreted by curl itself. Note that these letters are not normal legal URL contents but they should be encoded according to the URI standard.
And the -6
means to use IPv6 only:
If libcurl is capable of resolving an address to multiple IP versions (which it is if it is IPv6-capable), this option tells libcurl to resolve names to IPv6 addresses only.
But reading that functionality description, it seems like -6
is not really needed for a pure IPv6 address; only if one is using curl
on a hostname that has an IPv4 and IPv6 address connected to it so it would prefer the IPv6. Just something to note.
From "curl --manual", I found this:
curl -g "http://[2001:1890:1112:1::20]/"
or
curl "http://[2001:1890:1112:1::20]/"
So, for the address you're asking about, try:
curl -g "http://[::1]:8080/"
However, you may want to run:
curl -V
and see if IPv6 shows up on the line that says "Features" (the third line, not counting extra lines from word wrapping). I found my version didn't. cURL download page has various links for operating systems, including curl 7.41.0 download site (which is currently the latest version) for Microsoft Windows. That page has multiple executables (available for Microsoft Windows); the first one I found did not support IPv6. But the two described as "ipv6-sspi-spnego-winssl" (one for x86 and one for x64) did : curl -V did show IPv6. So be careful about which package you download.