Repository navigation
Description
What is the issue?
When tailscaled serves TCP from its own netstack (here tailscale serve --https=443 on a node in userspace-networking mode), and the netstack side closes a connection first, gVisor keeps that 4-tuple in TIME_WAIT for DefaultTCPTimeWaitTimeout, 60 seconds.
If the client picks the same source port again within that minute, every SYN of the new connection is dropped: no SYN-ACK and no RST.
The client's kernel has long since freed the port, so Linux reusing it is legitimate.
The client sees a connect that hangs until its own timeout, while the peer is online and its WireGuard traffic keeps arriving.
Expected: the new connection is accepted, as a Linux kernel TCP server in TIME_WAIT accepts a SYN with a higher sequence number (RFC 1122 4.2.2.13), or at least answered with a reset so the client fails fast.
Why it happens, from reading the code (tailscale main, gVisor at the pinned a6f909f08a72):
receiver.handleTimeWaitSegment(pkg/tcpip/transport/tcp/rcv.go) drops RSTs, returnsnewSynfor a SYN whose sequence number is aboveRcvNxt, and drops any other segment that has no ACK.Endpoint.handleTimeWaitSegments(pkg/tcpip/transport/tcp/connect.go) hands anewSynsegment on only whenFindTransportEndpointfinds an endpoint inStateListenfor the local address and port.wgengine/netstack/netstack.goaccepts TCP throughtcp.NewForwarder, not a listening endpoint, so there is never one to find, and the SYN is dropped.- tailscaled does not set
tcpip.TCPTimeWaitTimeoutOption, and offers no knob for it (onlyTS_NETSTACK_KEEPALIVE_IDLEandTS_NETSTACK_KEEPALIVE_INTERVAL).
In our case it surfaced as docker login against a registry behind tailscale serve timing out after 15 seconds, once in about two weeks of CI pushes:
Error response from daemon: Get "https://<registry>.ts.net/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
The client node's tailscaled logged, during that login:
open-conn-track: timeout opening (TCP <client>:58775 => <server>:443) to node [xxxxx]; online=yes, lastRecv=13s
open-conn-track: timeout opening (TCP <client>:58775 => <server>:443) to node [xxxxx]; online=yes, lastRecv=2s
open-conn-track: timeout opening (TCP <client>:58775 => <server>:443) to node [xxxxx]; online=yes, lastRecv=8s
open-conn-track: timeout opening (TCP <client>:58775 => <server>:443) to node [xxxxx]; online=yes, lastRecv=2s
The server node logged nothing for it, and the HTTP server behind serve saw no request.
Steps to reproduce
Server node: tailscaled in userspace-networking mode, with tailscale serve --https=443 in front of a local HTTP server.
Client node: any Linux node on the same tailnet.
- From the client, bind a fixed source port, open a TLS connection to the server node's tailnet address on 443, send an HTTP/1.1 request with
Connection: close, read the response to EOF, and close without sending TLSclose_notify.
The server side closes first, so the server's netstack holds the 4-tuple in TIME_WAIT. - Within 60 seconds, bind the same source port again and connect to the same address and port.
Observed: the second connect took 69.2 seconds (the SYN retransmits until the TIME_WAIT expired), and the client's tailscaled logged the same open-conn-track: timeout opening ... online=yes lines for that port.
Control: when the client sends close_notify before closing, the server answers with a reset rather than entering TIME_WAIT, and the next connect from the same port succeeds at once.
Are there any recent changes that introduced the issue?
Not that we know of. The TIME_WAIT path and the forwarder look unchanged on main.
Possible fixes:
- Let a valid TIME_WAIT-reusing SYN reach the stack's forwarder when no listening endpoint exists, as Linux accepts it for a listener (this may be a gVisor change).
- Or set
tcpip.TCPTimeWaitTimeoutOptionon tailscaled's stack, with a shorter default or aTS_NETSTACK_*knob beside the keepalive ones.
OS
Linux
OS version
Ubuntu 24.04.4 LTS under WSL2 (Windows build 10.0.26300), kernel 6.18.54.1-microsoft-standard-WSL2, on both nodes
Tailscale version
1.104.2 on both nodes
Other software
Docker 29.9.1 as the client; zot as the HTTP server behind tailscale serve.
Bug report
Not attached.
Activity
adios-404 commentedon Oct 31, 2026
Thanks for the detailed report. This matches gvisor/gvisor#15013 in gVisor's netstack, and gvisor/gvisor#15019 is the pending fix (open since Sep 25, not reviewed yet).
Your reading of the code is right: on 1.104.2 every serve connection from a peer goes through that forwarder (netstack.go#L643-L645). TUN mode would not avoid it, because netstack still takes the serve, SSH and peerAPI ports there (netstack.go#L1261-L1281).
The PR's non-test diff applies cleanly to 1.104's gVisor pin. I tested two gVisor stacks in one process, with a forwarder-only server that closes first:
A shorter TIME_WAIT helps but does not fix it: with a 1 s
TCPTimeWaitTimeoutOption, stalls still happened in daaain's Lima tests, each about 1 s (the client's first SYN retransmission).Where you control the client, closing with
SO_LINGER0 avoided it in reports on both gVisor threads: as in yourclose_notifycontrol, netstack then keeps no TIME_WAIT.bcreane commentedon Nov 12, 2026
Thanks for the thorough report, and thanks @adios-404 for the measurements.
I was able to reproduce this against the gVisor commit we currently pin, using a forwarder-only server that closes first. A reconnect from the same source port stalls until TIME_WAIT expires, and with the non-test part of gvisor/gvisor#15019 applied the same reconnect goes through immediately. Shortening the TIME_WAIT timeout on our side would only reduce the stall to about a second, since the client's first SYN retransmission still has to wait, so it doesn't look like a real fix.
The right fix appears to be the upstream gVisor change. cc @raggi, you've been handling our gVisor updates - I think we need to track gvisor/gvisor#15019 and bump our commit once it merges.
Ramblurr commentedon Nov 23, 2026
Same bug on the subnet-route / exit-node forwarding path, with stock tailscaled 1.104.6 in
--tun=userspace-networkingand nothing in front. A advertises 192.168.2.0/24, where C runs nginx with its default config. From client B:abreports aConnectmax of about 68000 ms. On B's tailscale0 there's a SYN on the same port 28 ms after the server-closed flow, 10 retransmits, and a SYN-ACK 68.4 s later. In kernel TUN mode the same commands show no stall.