{"record":{"id":"925228532a778069","repo":"cloudflare/quiche","slug":"connect-to-is-expected-to-be-a-string-containing","errorCode":null,"errorMessage":"--connect-to is expected to be a string containing an IPv4 or IPv6 address with a port. E.g. 192.0.2.0:443","messagePattern":"--connect-to is expected to be a string containing an IPv4 or IPv6 address with a port\\. E\\.g\\. 192\\.0\\.2\\.0:443","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/src/client.rs","lineNumber":66,"sourceCode":"    args: ClientArgs, conn_args: CommonArgs,\n    output_sink: impl FnMut(String) + 'static,\n) -> Result<(), ClientError> {\n    let mut buf = [0; 65535];\n    let mut out = [0; MAX_DATAGRAM_SIZE];\n\n    let output_sink =\n        Rc::new(RefCell::new(output_sink)) as Rc<RefCell<dyn FnMut(_)>>;\n\n    // Setup the event loop.\n    let mut poll = mio::Poll::new().unwrap();\n    let mut events = mio::Events::with_capacity(1024);\n\n    // We'll only connect to the first server provided in URL list.\n    let connect_url = &args.urls[0];\n\n    // Resolve server address.\n    let peer_addr = if let Some(addr) = &args.connect_to {\n        addr.parse().expect(\"--connect-to is expected to be a string containing an IPv4 or IPv6 address with a port. E.g. 192.0.2.0:443\")\n    } else {\n        *connect_url.socket_addrs(|| None).unwrap().first().unwrap()\n    };\n\n    // Bind to INADDR_ANY or IN6ADDR_ANY depending on the IP family of the\n    // server address. This is needed on macOS and BSD variants that don't\n    // support binding to IN6ADDR_ANY for both v4 and v6.\n    let bind_addr = match peer_addr {\n        std::net::SocketAddr::V4(_) => format!(\"0.0.0.0:{}\", args.source_port),\n        std::net::SocketAddr::V6(_) => format!(\"[::]:{}\", args.source_port),\n    };\n\n    // Create the UDP socket backing the QUIC connection, and register it with\n    // the event loop.\n    let mut socket =\n        mio::net::UdpSocket::bind(bind_addr.parse().unwrap()).unwrap();\n    poll.registry()\n        .register(&mut socket, mio::Token(0), mio::Interest::READABLE)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/cloudflare/quiche/blob/9f96daa2c22a4468b0036fb0a0a3894eee6498b8/apps/src/client.rs#L48-L84","documentation":"quiche-client validates the --connect-to CLI value by parsing it directly with expect(), which panics if the string is not a valid SocketAddr (an IP:port literal, not a hostname). The panic message instructs the user on the expected format.","triggerScenarios":"Running quiche-client with --connect-to set to something like example.com:443 (a hostname) or a malformed address like 192.0.2.0 (missing port) — addr.parse::<SocketAddr>() fails in connect().","commonSituations":"Users assuming --connect-to accepts DNS names (it requires literal IPs); typos or missing port; copying curl-style --connect-to syntax which differs.","solutions":["Pass a literal IP with port, e.g. --connect-to 192.0.2.0:443","Resolve the hostname externally (dig/host) and use the resulting IP","Patch the code to resolve hostnames before parse if you control the build"],"exampleFix":"// before\nquiche-client --connect-to example.com:443 https://example.com/\n// after\nquiche-client --connect-to 93.184.216.34:443 https://example.com/","handlingStrategy":"validation","validationCode":"let addr: std::net::SocketAddr = connect_to.parse().map_err(|_|\n    anyhow!(\"--connect-to must be an IPv4/IPv6 address with port, e.g. 192.0.2.0:443\"))?;","typeGuard":"fn is_socketaddr_literal(s: &str) -> bool {\n    s.parse::<std::net::SocketAddr>().is_ok()\n}","tryCatchPattern":null,"preventionTips":["Remember --connect-to requires a literal IP:port, not a hostname","Resolve hostnames with dig/host before passing","Validate the argument with a SocketAddr parse before launching the client"],"tags":["cli","quiche-client","panic","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"9f96daa2c22a4468b0036fb0a0a3894eee6498b8","analyzedAt":"2026-09-08T11:27:09.536Z","contentChangedAt":"2026-09-08T11:27:09.536Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}