{"record":{"id":"1f12fd50dbb48e45","repo":"junegunn/fzf","slug":"invalid-listen-port-s","errorCode":null,"errorMessage":"invalid listen port: %s","messagePattern":"invalid listen port: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/server.go","lineNumber":73,"sourceCode":"\nvar defaultListenAddr = listenAddress{\"localhost\", 0, \"\"}\n\nfunc parseListenAddress(address string) (listenAddress, error) {\n\tif strings.HasSuffix(address, \".sock\") {\n\t\treturn listenAddress{\"\", 0, address}, nil\n\t}\n\n\tparts := strings.SplitN(address, \":\", 3)\n\tif len(parts) == 1 {\n\t\tparts = []string{\"localhost\", parts[0]}\n\t}\n\tif len(parts) != 2 {\n\t\treturn defaultListenAddr, fmt.Errorf(\"invalid listen address: %s\", address)\n\t}\n\tportStr := parts[len(parts)-1]\n\tport, err := strconv.Atoi(portStr)\n\tif err != nil || port < 0 || port > 65535 {\n\t\treturn defaultListenAddr, fmt.Errorf(\"invalid listen port: %s\", portStr)\n\t}\n\tif len(parts[0]) == 0 {\n\t\tparts[0] = \"localhost\"\n\t}\n\treturn listenAddress{parts[0], port, \"\"}, nil\n}\n\nfunc startHttpServer(address listenAddress, actionChannel chan []*action, getHandler func(getParams) string) (net.Listener, int, error) {\n\thost := address.host\n\tport := address.port\n\tapiKey := os.Getenv(\"FZF_API_KEY\")\n\tif !address.IsLocal() && len(apiKey) == 0 {\n\t\treturn nil, port, errors.New(\"FZF_API_KEY is required to allow remote access\")\n\t}\n\n\tvar listener net.Listener\n\tvar err error\n\tif len(address.sock) > 0 {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/server.go#L55-L91","documentation":"The host:port in --listen was structurally valid, but the port component failed strconv.Atoi or fell outside 0-65535. Port 0 is allowed and asks the kernel for an ephemeral port; anything non-numeric, negative, or above 65535 is rejected.","triggerScenarios":"Passing --listen=localhost:99999, --listen=localhost:-1, --listen=localhost:6266x, or a service name ('localhost:http') instead of a number.","commonSituations":"Off-by-one typos in port numbers; copying URLs where the port got concatenated with a path ('6266/api'); using named services instead of numeric ports.","solutions":["Use a numeric port in 0-65535, e.g. --listen=localhost:6266","Pick an unused port for a fixed listener; fzf also prints the chosen port when 0 is used","Check for stray characters after the port"],"exampleFix":"# before\nfzf --listen=localhost:99999\n# after\nfzf --listen=localhost:6266","handlingStrategy":"validation","validationCode":"# validate the port component in shell\nport=\"${ADDR##*:}\"\ncase \"$port\" in\n  ''|*[!0-9]*) echo \"bad port: $port\" >&2; exit 1;;\nesac\n[ \"$port\" -le 65535 ] || { echo \"port out of range: $port\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use numeric ports only; service names like http are not supported","Double-check for trailing path or query text glued onto the port"],"tags":["fzf","server","listen","port","validation"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}