Skip to main content

Tunnel fails to connect because of IPv6

If the host has IPv6, the tuna client may connect to us over it. Usually you won't notice, but on some hosts IPv4 and IPv6 belong to different networks, and the tunnel can't connect over IPv6. We've seen this on VPS hosts.

Symptoms​

IPv6 is most likely the cause if the host has IPv6 and:

  • the tunnel keeps reconnecting or times out while connecting to a node;
  • latency through the tunnel is noticeably higher.

Diagnosis​

Check which addresses the host uses to reach the internet and which country they are registered in:

curl -4 https://ifconfig.co/country
curl -6 https://ifconfig.co/country

If the second command returns an answer, the host has IPv6. If the countries differ, this is almost certainly your case.

A detailed connection log shows which addresses the client connects to and where the connection breaks:

tuna http 8080 --log-level=debug

For a general network check, use tuna diagnose.

Fix​

Set the TUNA_FORCE_IPV4=1 environment variable. With it, the client connects to the API and nodes over IPv4 only, and falls back to public DNS servers if the system DNS doesn't work. The variable is available in tuna-cli 0.31.0 and later.

TUNA_FORCE_IPV4=1 tuna http 8080

systemd service​

If the tunnel is installed as a service, add the variable in a drop-in. The default service name is tuna; a custom one is set with --name:

sudo systemctl edit tuna
[Service]
Environment=TUNA_FORCE_IPV4=1
sudo systemctl restart tuna

Docker​

Pass the variable with -e TUNA_FORCE_IPV4=1 in docker run, or under environment in Docker Compose:

services:
tuna:
image: yuccastream/tuna:latest
command: http app:8080
environment:
TUNA_API_KEY: tak_***
TUNA_FORCE_IPV4: "1"

Still not working? Contact support and attach the tuna diagnose output and a log with --log-level=debug.