go-kratos/kratos · error
failed to extract port: %v
Error message
failed to extract port: %v
What it means
Error "failed to extract port: %v" thrown in go-kratos/kratos.
Source
Thrown at internal/host/host.go:42
// Port return a real port.
func Port(lis net.Listener) (int, bool) {
if addr, ok := lis.Addr().(*net.TCPAddr); ok {
return addr.Port, true
}
return 0, false
}
// Extract returns a private addr and port.
func Extract(hostPort string, lis net.Listener) (string, error) {
addr, port, err := net.SplitHostPort(hostPort)
if err != nil && lis == nil {
return "", err
}
if lis != nil {
p, ok := Port(lis)
if !ok {
return "", fmt.Errorf("failed to extract port: %v", lis.Addr())
}
port = strconv.Itoa(p)
}
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
return net.JoinHostPort(addr, port), nil
}
ifaces, err := net.Interfaces()
if err != nil {
return "", err
}
var (
minIndex = 0
ips = make([]net.IP, 0, 1)
)
for _, iface := range ifaces {
if iface.Flags&net.FlagUp == 0 {
continue
}View on GitHub (pinned to 668db92c2c)
When it happens
Trigger: Thrown at internal/host/host.go:42 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/d249e62edcd312e3.
Report an issue: GitHub.