Skip to content

IPv6 localhost not supported #583

Open

Description

@ujwal-setlur

Description

Hi,

I am using node 18 on OS X Ventura 13.1, and the pg client resolves localhost to ::1 which Colima cannot handle. The connection fails. If I use 127.0.0.1, it works. I believe this is because node 18 does enforce IPv4 resolution first anymore, and Colima cannot handle a IPv6 address. But Docker Desktop handles it just fine. Any chances of getting this addressed?

Thanks!

Version

Colima Version: 0.5.2
Lima Version:
Qemu Version:

Operating System

  • macOS Intel <= 12 (Monterrey)
  • macOS Intel >= 13 (Ventura)
  • macOS M1 <= 12 (Monterrey)
  • macOS M1 >= 13 (Ventura)
  • Linux

Output of colima status

No response

Reproduction Steps

  1. Fire up Postgres container.
  2. Run node 18 code to connect to it via localhost. It will resolve to ::1 (IPv6)
  3. Connection failure

Expected behaviour

Should connect.

Additional context

Docker Desktop works.

Activity

  1. henrik242 commented on Jan 30, 2023

    @henrik242

    You can work around this by commenting out ::1 localhost in /etc/hosts. Not the best solution, but better than nothing..

    SEO: We had this problem when using testcontainers-node. Error: Failed to connect to Reaper and Error: No Docker client strategy found wasn't straight forward to debug. Setting TESTCONTAINERS_HOST_OVERRIDE=127.0.0.1 also works.

  2. henrik242 commented on Jan 30, 2023

    @henrik242

    Maybe related: lima-vm/lima#1330

  3. shlomioz commented on Feb 12, 2023

    @shlomioz

    Same issue for me.

  4. mxngls commented on Feb 24, 2023

    @mxngls

    Not quite sure if thats exactly related, but I had the same problem while connecting a local node application to a (locally running) docker container. What helped in my case was to specify the socket option when creating the Redis client:

    export const redisClient = redis.createClient({
      // url: process.env.REDIS_URL,
      socket: {
        host: "127.0.0.1",
        port: 6379,
      },
      legacyMode: true,
    });

    When using Docker Desktop this setup was not necessary.

  5. sabberworm commented on Mar 9, 2023

    @sabberworm

    You can work around this by commenting out ::1 localhost in /etc/hosts. Not the best solution, but better than nothing..

    This did not work for me. I suspect the resolution of localhost is done by some clients without going through the hosts file.

    What did work was manually changing all connection strings to reference 127.0.0.1 instead of localhost.

    I agree, though, that the real fix would be for colima to additionally bind to [::1] whenever it binds to 127.0.0.1 implicitly (same goes for [::] when the implicit binding is to 0.0.0.0).

  6. acuteaura commented on Mar 20, 2023

    @acuteaura

    I'm using colima to run a VPN alongside a socks5 server, and it looks like I need to remove IPv6 addresses and routes from my config files.

    docker run -v (pwd)/<wg config with v6>.conf:/etc/wireguard/vpn.conf --cap-add=NET_ADMIN --rm local/wgd:latest
    [#] ip link add vpn type wireguard
    [#] wg setconf vpn /dev/fd/63
    [#] ip -4 address add 10.66.140.107/32 dev vpn
    [#] ip -6 address add fc00:bbbb:bbbb:bb01::3:8c6a/128 dev vpn
    RTNETLINK answers: Permission denied
    [#] ip link delete dev vpn
    
  7. abiosoft commented on Mar 20, 2023

    @abiosoft
    Owner

    Maybe related: lima-vm/lima#1330

    Yeah it is. Ipv6 is not properly supported in Lima yet.

  8. genki commented on Mar 23, 2023

    @genki

    Facing similar issue.
    Is there a way to disable IPv6 and use only IPv4?

  9. earcherc commented on Aug 28, 2023

    @earcherc

    bump

  10. added a commit that references this issue on Apr 9, 2025
  11. f-moya commented on Jul 30, 2025

    @f-moya

    I encountered the same issue and it took some time to identify the cause. Since Docker Desktop supports this out of the box, perhaps we could add a note in the documentation to clarify it for others?

  12. toutane commented on May 5, 2026

    @toutane

    Still reproducible on Colima 0.10.1 on macOS. Adding a more concrete diagnosis in case it helps.

    The Lima config generated by Colima (~/.colima/_lima/colima/lima.yaml) only declares IPv4 port forwards : 0.0.0.0 and 127.0.0.1, no :: or ::1. On macOS, /etc/hosts maps localhost to both 127.0.0.1 and ::1, and per RFC 6724 the resolver returns IPv6 first. So any client connecting to the first resolved address gets connection refused. Docker Desktop doesn't have this issue because it publishes on both loopbacks.

    Not specific to Node.js / Postgres, I hit it from Rust (std::net::ToSocketAddrs) running integration tests against a containerized Hive Metastore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions