{"record":{"id":"0a46c49425b0c411","repo":"junegunn/fzf","slug":"invalid-listen-address-s","errorCode":null,"errorMessage":"invalid listen address: %s","messagePattern":"invalid listen address: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/server.go","lineNumber":68,"sourceCode":"}\n\nfunc (addr listenAddress) IsLocal() bool {\n\treturn addr.host == \"localhost\" || addr.host == \"127.0.0.1\" || len(addr.sock) > 0\n}\n\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\")","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/junegunn/fzf/blob/bd4efa277b49ef34ca4025bff9b1a288e1980eff/src/server.go#L50-L86","documentation":"The --listen address could not be parsed. parseListenAddress accepts '<port>', '<host>:<port>', or a path ending in '.sock'; anything that splits into something other than exactly 2 host/port parts (after a max-3 SplitN) is rejected as an invalid listen address.","triggerScenarios":"Passing --listen with more than one colon and a non-socket value, e.g. 'a:b:c', or an empty address that is not a .sock path; IPv6 literals like '::1:6266' also split wrong because SplitN on ':' produces 3 parts.","commonSituations":"Using IPv6 addresses without bracket notation; typos like '--listen=:6266:extra'; passing URLs ('http://localhost:6266') instead of host:port.","solutions":["Use the simple forms: --listen, --listen=6266, --listen=localhost:6266, or --listen=/path/server.sock","For IPv6, rely on 'localhost' resolution rather than a raw literal, or ensure bracketed forms supported by your fzf version","Do not include a scheme; strip http:// before passing"],"exampleFix":"# before\nfzf --listen=http://0.0.0.0:6266\n# after\nfzf --listen=0.0.0.0:6266","handlingStrategy":"validation","validationCode":"# validate before passing to --listen\nvalid_listen() {\n  case \"$1\" in\n    *.sock|[0-9]*|\"\"|localhost:[0-9]*|127.0.0.1:[0-9]*|\\[*\\]:[0-9]*) return 0;;\n    *:*) printf '%s' \"$1\" | grep -Eq '^[^:]+:[0-9]+$' && return 0;;\n  esac\n  return 1\n}\nvalid_listen \"$ADDR\" || { echo \"bad listen address: $ADDR\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use host:port, bare port, or *.sock forms","Strip schemes like http:// before passing an address"],"tags":["fzf","server","listen","address","validation"],"backgroundTag":null,"analyzedSha":"bd4efa277b49ef34ca4025bff9b1a288e1980eff","analyzedAt":"2026-08-15T06:11:46.983Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}