Fetch() in workers cannot connect IPv6 hosts

I tried to use fetch() to connect to one of my websites hosted on IPv6 networks only, but it returned:

connect(): Network is unreachable

Code pasted here:

async function handleRequest(request) {
      request = new Request(request)
      request.headers.set('Host', 'ipv6.google.com')
      const URL = 'https://ipv6.google.com'
      let response = await fetch(URL, request)
      response = new Response(response.body, response)
      return response
    }

I replaced the URL with https://ipv6.google.com, which is also hosted on IPv6 networks only. The error still appears.

Is workers backend connected to the IPv6 network? If not, when will the access be available?

Thanks.

True. Just tested the same code with https://ipv4.icanhazip.com/ and https://ipv6.icanhazip.com/, ipv6 fails.

I looked further into this and only fails IPv6 in development, once deployed across Cloudflare PoPs it does support iPv6.

3 Likes