Issue: "Cannot assign requested address" when connecting to ::1


With a .travis.yml set to:

language: python     
    - "3.5"          
    - python3


import socket                                         
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect(('::1', 1234))                              

As can be seen here, I’m getting this error on Travis:

[Errno 99] Cannot assign requested address

The expected behavior is:

[Errno 111] Connection refused

(Note: this is a duplicate of IPv6 sockets returning "Cannot assign requested address" · Issue #8711 · travis-ci/travis-ci · GitHub , and "Cannot assign requested address" when connecting to ::1 · Issue #10350 · travis-ci/travis-ci · GitHub which got closed)

There’s actually a Github repo dedicated to testing Travis IPv6 support! As of now, it says that only container-based Linuxes and MacOS have IPv6 addresses assigned, and only loopback and link-local at that.

Thanks for your help. I tried setting “sudo: false”, there is no noticeable change :confused:

I’ve rerun the tests, adding Xenial to the mix, too. There’s no IPv6 support in any of the Linuxes, only in MacOS.

With sudo: required, you might be able to enable it yourself if the kernel has the necessary modules.

These commands had no effect:

sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.lo.disable_ipv6=0

sysctl -w reconfigures the kernel. Obviously, you need to run it with superuser rights.