diff --git a/p2p/server.go b/p2p/server.go index c87b7758d..1fe5f3978 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -562,7 +562,11 @@ func (srv *Server) setupDiscovery() error { srv.log.Debug("UDP listener up", "addr", realaddr) if srv.NAT != nil { if !realaddr.IP.IsLoopback() { - go nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") + srv.loopWG.Add(1) + go func() { + nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") + srv.loopWG.Done() + }() } } srv.localnode.SetFallbackUDP(realaddr.Port)