{"record":{"id":"480ec31773aefae9","repo":"BigPizzaV3/CodexPlusPlus","slug":"failed-to-query-cdp-targets-on-loopback-addresses","errorCode":null,"errorMessage":"failed to query CDP targets on loopback addresses: {}","messagePattern":"failed to query CDP targets on loopback addresses: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/cdp.rs","lineNumber":139,"sourceCode":"    let client = reqwest::Client::builder()\n        .no_proxy()\n        .timeout(CDP_HTTP_TIMEOUT)\n        .build()\n        .context(\"failed to build CDP HTTP client\")?;\n\n    let urls = [\n        format!(\"http://127.0.0.1:{debug_port}/json\"),\n        format!(\"http://[::1]:{debug_port}/json\"),\n    ];\n    let mut errors = Vec::new();\n    for url in urls {\n        match query_targets_url(&client, &url, debug_port).await {\n            Ok(targets) => return Ok(targets),\n            Err(error) => errors.push(format!(\"{url}: {error:#}\")),\n        }\n    }\n\n    bail!(\n        \"failed to query CDP targets on loopback addresses: {}\",\n        errors.join(\"; \")\n    )\n}\n\npub async fn browser_identity(debug_port: u16) -> anyhow::Result<CdpBrowserIdentity> {\n    let client = reqwest::Client::builder()\n        .no_proxy()\n        .timeout(CDP_HTTP_TIMEOUT)\n        .build()\n        .context(\"failed to build CDP HTTP client\")?;\n    let urls = [\n        format!(\"http://127.0.0.1:{debug_port}/json/version\"),\n        format!(\"http://[::1]:{debug_port}/json/version\"),\n    ];\n    let mut errors = Vec::new();\n    for url in urls {\n        let result = async {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/cdp.rs#L121-L157","documentation":"Thrown by `list_targets` after it has tried querying the CDP `/json` target list on every loopback address candidate (IPv4 and IPv6) and all attempts failed. It aggregates each URL's underlying error into a single message so the caller can see why every loopback candidate was rejected.","triggerScenarios":"Calling `list_targets(debug_port)` when no browser is listening on the port, the browser only binds an address not in the candidate list, HTTP requests fail or return non-list payloads, or the port is occupied by a non-CDP service.","commonSituations":"Chromium not started with `--remote-debugging-port`, wrong debug_port passed, browser still starting up, firewall/proxy interference, or a service other than Chrome listening on the port.","solutions":["Confirm the browser runs with `--remote-debugging-port=<port>` and that the port matches the one passed to `list_targets`","Read the per-URL errors embedded in the message — connection-refused vs HTTP errors point to different causes (browser down vs wrong protocol)","Check `curl http://127.0.0.1:<port>/json/list` manually to see what the endpoint returns","Retry after a short delay if the browser was just launched"],"exampleFix":"// before\nlet targets = cdp::list_targets(9222).await?; // browser not launched yet\n// after\nlet child = launch_chrome([\"--remote-debugging-port=9222\"])?;\nwait_for_endpoint_available(9222, Duration::from_secs(10)).await?;\nlet targets = cdp::list_targets(9222).await?;","handlingStrategy":"retry","validationCode":"async fn cdp_ready(port: u16) -> bool {\n    reqwest::get(format!(\"http://127.0.0.1:{port}/json/version\")).await\n        .map(|r| r.status().is_success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match cdp::list_targets(port).await {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"connection refused\") => retry_with_backoff(3, || cdp::list_targets(port)).await?,\n    Err(e) => return Err(e),\n}","preventionTips":["Launch the browser with --remote-debugging-port before calling","Wait for endpoint availability after browser startup","Keep the debug_port constant between launch and query"],"tags":["cdp","network","loopback","http"],"backgroundTag":"http-request-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}