diff --git a/ipn/ipnlocal/serve.go b/ipn/ipnlocal/serve.go index 83415fefb..0b5d5e89a 100644 --- a/ipn/ipnlocal/serve.go +++ b/ipn/ipnlocal/serve.go @@ -150,6 +150,14 @@ func (s *localListener) Run() { tcp4or6 = "tcp6" } + // while we were backing off and trying again, the context got canceled + // so don't bind, just return, because otherwise there will be no way + // to close this listener + if s.ctx.Err() != nil { + s.logf("localListener context closed before binding") + return + } + ln, err := lc.Listen(s.ctx, tcp4or6, net.JoinHostPort(ipStr, fmt.Sprint(s.ap.Port()))) if err != nil { if s.shouldWarnAboutListenError(err) {