{"record":{"id":"49fdd602963aa74f","repo":"oauth2-proxy/oauth2-proxy","slug":"unable-to-get-ip-and-port-from-http-remoteaddr-s","errorCode":null,"errorMessage":"unable to get ip and port from http.RemoteAddr (%s)","messagePattern":"unable to get ip and port from http\\.RemoteAddr \\((.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ip/realclientip.go","lineNumber":84,"sourceCode":"// GetClientIP obtains the perceived end-user IP address from headers if p != nil else from req.RemoteAddr.\nfunc GetClientIP(p ipapi.RealClientIPParser, req *http.Request) (net.IP, error) {\n\tif p != nil {\n\t\treturn p.GetRealClientIP(req.Header)\n\t}\n\treturn getRemoteIP(req)\n}\n\n// getRemoteIP obtains the IP of the low-level connected network host\nfunc getRemoteIP(req *http.Request) (net.IP, error) {\n\t// Unix domain sockets set RemoteAddr to \"@\" which has no meaningful IP.\n\t// https://github.com/golang/go/blob/0fa53e41f122b1661d0678a6d36d71b7b5ad031d/src/syscall/syscall_linux.go#L506-L511\n\tif req.RemoteAddr == \"@\" {\n\t\treturn nil, nil\n\t}\n\n\t//revive:disable:indent-error-flow\n\tif ipStr, _, err := net.SplitHostPort(req.RemoteAddr); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get ip and port from http.RemoteAddr (%s)\", req.RemoteAddr)\n\t} else if ip := net.ParseIP(ipStr); ip != nil {\n\t\treturn ip, nil\n\t} else {\n\t\treturn nil, fmt.Errorf(\"unable to parse ip (%s)\", ipStr)\n\t}\n\t//revive:enable:indent-error-flow\n}\n\n// GetClientString obtains the human readable string of the remote IP and optionally the real client IP if available\nfunc GetClientString(p ipapi.RealClientIPParser, req *http.Request, full bool) (s string) {\n\tvar realClientIPStr string\n\tif p != nil {\n\t\tif realClientIP, err := p.GetRealClientIP(req.Header); err == nil && realClientIP != nil {\n\t\t\trealClientIPStr = realClientIP.String()\n\t\t}\n\t}\n\n\tvar remoteIPStr string","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/oauth2-proxy/oauth2-proxy/blob/33c2eb92dea78204f7a18bc2dfdbccc220f39257/pkg/ip/realclientip.go#L66-L102","documentation":"Parse failure in getRemoteIP: req.RemoteAddr is not in host:port form (and is not the \"@\" unix-socket sentinel), so the transport-level peer address cannot be turned into a net.IP. Typically caused by a custom listener or test harness producing a non-standard RemoteAddr.","triggerScenarios":"Thrown at pkg/ip/realclientip.go:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the server is reached over TCP so RemoteAddr is host:port","For unix sockets the \"@\" case is already handled; fix custom listeners to set a parseable RemoteAddr","In tests, use httptest or set RemoteAddr to a valid host:port"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"33c2eb92dea78204f7a18bc2dfdbccc220f39257","analyzedAt":"2026-09-06T08:51:53.077Z","contentChangedAt":"2026-09-06T08:51:53.077Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}