kovidgoyal/kitty · error

Unknown network type: %#v in socket address: %s

Error message

Unknown network type: %#v in socket address: %s

What it means

ParseSocketAddress recognized networks are unix, tcp/tcp4/tcp6, ip/ip4/ip6, and fd. Anything else before the colon yields this unknown-network-type error — the spec had a colon, but the prefix is not a supported network.

Source

Thrown at tools/utils/sockets.go:48

			network = "ip"
		}
		return
	}
	if network == "ip" || network == "ip6" || network == "ip4" {
		host := ipaddr.NewHostName(addr)
		if !host.IsAddress() {
			err = fmt.Errorf("Not a valid IP address: %#v. Cannot use: %s", addr, spec)
		}
		return
	}
	if network == "fd" {
		fd := -1
		if fd, err = strconv.Atoi(addr); err != nil || fd < 0 {
			err = fmt.Errorf("Not a valid file descriptor number: %#v. Cannot use: %s", addr, spec)
		}
		return
	}
	err = fmt.Errorf("Unknown network type: %#v in socket address: %s", network, spec)
	return
}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Prefix with a supported network: tcp:localhost:8080.
  2. Fix typos in the network name (unix, tcp, tcp4, tcp6, ip, ip4, ip6, fd).
  3. Strip URL schemes (https://) before passing — this API takes socket specs, not URLs.
  4. Add an allowlist validation check at config load time.

Example fix

// before
net, addr, err := utils.ParseSocketAddress("localhost:8080")
// after
net, addr, err := utils.ParseSocketAddress("tcp:localhost:8080")
Defensive patterns

Strategy: validation

Validate before calling

var okNets = map[string]bool{"unix":true,"tcp":true,"tcp4":true,"tcp6":true,"ip":true,"ip4":true,"ip6":true,"fd":true}
net, _, _ := strings.Cut(spec, ":")
if !okNets[net] {
    spec = "tcp:" + spec // common fix for missing prefix
}

Type guard

func hasKnownNetwork(spec string) bool {
    net, _, _ := strings.Cut(spec, ":")
    switch net {
    case "unix", "tcp", "tcp4", "tcp6", "ip", "ip4", "ip6", "fd":
        return true
    }
    return false
}

Try / catch

net, addr, err := utils.ParseSocketAddress(spec)
if err != nil && strings.Contains(err.Error(), "Unknown network type") {
    net, addr, err = utils.ParseSocketAddress("tcp:" + spec)
}

Prevention

When it happens

Trigger: Specs like localhost:8080 (missing tcp: prefix, so network='localhost'), https:example.com, ws:..., or typos like tpc:127.0.0.1:80.

Common situations: Users omitting the tcp: prefix for network addresses — 'localhost:8080' is the classic case — or pasting URLs into a socket-address config field.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/7a90310700dbf415. Report an issue: GitHub.