49

I tried a few ways but they seem to be confusing curl.

root@testt:~# curl localhost:8080
<h1>Hello world!</h1>

<p>Boom Bam Splat</p>
root@testt:~# curl ::1:8080
curl: (3) IPv6 numerical address used in URL without brackets
root@testt:~# curl [::1]:8080
curl: (3) [globbing] bad range specification in column 2
1
  • 2
    Thanks for giving the answers earlier! I was genuinely hard pressed for which to accept since they were both so concise and whatnot, though I chose the other since that user is just starting out compared to you and answered first. Regardless, just using the - g option was sufficient.
    – hak8or
    Mar 5, 2015 at 7:34

2 Answers 2

64

Update: As of December 28, 2022 and at least Curl version 7.68.0 one can simply use Curl like this, without the -g flag, and it works fine:

curl -6 "http://[::1]:8080/" 

Older answer below for reference.


Looking at the suggestions — and breakdown of common errors in 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.

2
  • 1
    I don't seem to need the -g flag. Just -6 is enough for me; this with curl 7.85
    – jeffmcc
    Dec 29, 2022 at 3:09
  • 1
    @jeffmcc Thanks for the comment! just tested using this with Curl 7.68.0 in macOS 13 (Ventura) and using just -6 works 100% fine for me as well. Will update my answer to reflect this. Dec 29, 2022 at 3:18
11

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .