{"record":{"id":"68a927e7803e14b2","repo":"openai/codex","slug":"network-target-rejected-by-policy","errorCode":null,"errorMessage":"network target rejected by policy","messagePattern":"network target rejected by policy","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/network-proxy/src/connect_policy.rs","lineNumber":72,"sourceCode":"                target,\n            })\n            .serve(input)\n            .await\n    }\n}\n\n#[derive(Clone)]\nstruct TargetCheckedStreamConnector {\n    state: Arc<NetworkProxyState>,\n    target: HostWithPort,\n}\n\nimpl TcpStreamConnector for TargetCheckedStreamConnector {\n    type Error = BoxError;\n\n    async fn connect(&self, addr: SocketAddr) -> Result<TcpStream, Self::Error> {\n        if is_non_public_ip(addr.ip()) && !self.allows_non_public_target(addr).await? {\n            return Err(io::Error::new(\n                io::ErrorKind::PermissionDenied,\n                \"network target rejected by policy\",\n            )\n            .into());\n        }\n\n        tokio::net::TcpStream::connect(addr)\n            .await\n            .map(TcpStream::from)\n            .map_err(Into::into)\n    }\n}\n\nimpl TargetCheckedStreamConnector {\n    async fn allows_non_public_target(&self, addr: SocketAddr) -> Result<bool, BoxError> {\n        if self.state.allow_local_binding().await.map_err(|err| {\n            let err: BoxError = err.into();\n            OpaqueError::from_boxed(err)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/network-proxy/src/connect_policy.rs#L54-L90","documentation":"TargetCheckedStreamConnector::connect blocked an outbound connection inside the network proxy: the resolved address is a non-public IP (loopback, private, link-local) and the proxy's policy state does not allow non-public targets for this stream. It surfaces as ErrorKind::PermissionDenied.","triggerScenarios":"Thrown at codex-rs/network-proxy/src/connect_policy.rs:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Allow the target host/IP via the proxy's non-public target policy configuration","Connect to a public address instead of the blocked internal one","Verify DNS isn't unexpectedly resolving an external name to an internal IP"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}