slackhq/nebula · error
unknown network type: %s
Error message
unknown network type: %s
What it means
Service.DialContext only supports a fixed set of network types (e.g. "tcp", "tcp4", "tcp6") mapped via getProtocolNumber. Any other network string falls into the default branch and this error is thrown. It means the requested network parameter is not a protocol the in-memory netstack dialer can handle.
Source
Thrown at service/service.go:199
Addr: tcpip.AddrFromSlice(addr.IP),
Port: uint16(addr.Port),
}
num := getProtocolNumber(addr.AddrPort().Addr())
return gonet.DialUDP(s.ipstack, nil, &fullAddr, num)
case "tcp", "tcp4", "tcp6":
addr, err := net.ResolveTCPAddr(network, address)
if err != nil {
return nil, err
}
fullAddr := tcpip.FullAddress{
NIC: nicID,
Addr: tcpip.AddrFromSlice(addr.IP),
Port: uint16(addr.Port),
}
num := getProtocolNumber(addr.AddrPort().Addr())
return gonet.DialContextTCP(ctx, s.ipstack, fullAddr, num)
default:
return nil, fmt.Errorf("unknown network type: %s", network)
}
}
// Dial dials the provided address
func (s *Service) Dial(network, address string) (net.Conn, error) {
return s.DialContext(context.Background(), network, address)
}
// Listen listens on the provided address. Currently only TCP with wildcard
// addresses are supported.
func (s *Service) Listen(network, address string) (net.Listener, error) {
if network != "tcp" && network != "tcp4" {
return nil, errors.New("only tcp is supported")
}
addr, err := net.ResolveTCPAddr(network, address)
if err != nil {
return nil, err
}View on GitHub (pinned to dd8f660c0a)
Solutions
- Change the network argument to a supported TCP variant ("tcp", "tcp4", or "tcp6").
- Validate/whitelist the network string before calling Dial and surface a clear error to your user.
- If UDP support is needed, extend getProtocolNumber/DialContext in service.go to map the new protocol number instead of hitting default.
Example fix
// before
conn, err := svc.Dial("udp", "10.0.0.1:53")
// after
conn, err := svc.Dial("tcp", "10.0.0.1:53") Defensive patterns
Strategy: validation
Validate before calling
var allowed = map[string]bool{"tcp": true, "tcp4": true, "tcp6": true}
if !allowed[network] {
return fmt.Errorf("unsupported network %q: use tcp, tcp4 or tcp6", network)
}
conn, err := svc.Dial(network, address) Type guard
func isSupportedNetwork(n string) bool {
switch n {
case "tcp", "tcp4", "tcp6":
return true
}
return false
} Try / catch
conn, err := svc.Dial(network, address)
if err != nil {
if strings.HasPrefix(err.Error(), "unknown network type") {
return fmt.Errorf("network %q not supported by netstack dialer", network)
}
return err
} Prevention
- Whitelist network strings at your API boundary instead of passing user input through.
- Check getProtocolNumber in service.go for the exact supported set before adding new call sites.
- Add a unit test asserting each network value you use is dialable.
When it happens
Trigger: Calling Service.Dial/DialContext with network values like "udp", "unix", "ip", "tcp" with typos, or empty string; the value reaches the switch's default case in DialContext (service/service.go:199).
Common situations: Passing user-supplied or config-driven network names straight into Dial; copying code from net.Dial examples using "udp" which this stack does not implement; typos like "tcp4" vs "tcp" mismatches when wiring gVisor netstack tests.
Related errors
- only wildcard address supported, got %q %v
- invalid port %d
- already listening on port %d
- could not enable TCP SACK: %v
- could not create netstack NIC: %v
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/35f99feec9cee5ac.
Report an issue: GitHub.