vectordotdev/vector · error

HTTP URI not valid

Error message

HTTP URI not valid

What it means

socketaddr_from_uri parses an HTTP URI to a SocketAddr for the validation HTTP server. It panics with "HTTP URI not valid" when the URI has no host, or the host is not a literal IPv4/IPv6 address (e.g. a DNS name), or the port cannot be parsed. The validation framework requires a raw socket address, not a resolvable hostname.

Solutions

  1. Replace the hostname in the URI with a literal IP address, e.g. http://127.0.0.1:8080.
  2. Ensure the URI includes both host and port components.
  3. Resolve the hostname to an IP beforehand and pass the IP form of the URI.

Example fix

// before
let uri = "http://localhost:8080";
// after
let uri = "http://127.0.0.1:8080";
Defensive patterns

Strategy: validation

Validate before calling

fn is_socketaddr_uri(u: &str) -> bool {
    url::Url::parse(u).ok()
        .and_then(|uri| uri.host_str().map(|h| h.parse::<std::net::IpAddr>().is_ok()))
        .unwrap_or(false)
        && url::Url::parse(u).unwrap().port().is_some()
}
// assert!(is_socketaddr_uri("http://127.0.0.1:8080"));

Type guard

fn has_ip_host(u: &url::Url) -> Option<std::net::IpAddr> {
    u.host_str()?.parse::<std::net::IpAddr>().ok()
}

Prevention

When it happens

Trigger: Calling spawn_http_server with a URI like "http://localhost:8080" or "http://example.com" (DNS name) or a URI missing the host/port entirely; any value that fails IpAddr::from_str or lacks uri.host().

Common situations: Pointing a validation test config at "localhost" instead of "127.0.0.1"; omitting the port; using a hostname that was valid in other Vector configs where DNS resolution is allowed.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/e60a59b4420fb9b9. Report an issue: GitHub.

Appendix: source

Thrown at src/components/validation/resources/http.rs:553

            error!(error = ?e, "HTTP server encountered an error.");
        }

        http_server_completed.mark_as_done();
    });

    (resource_notifier, http_server_shutdown_tx)
}

fn socketaddr_from_uri(uri: &Uri) -> SocketAddr {
    let uri_port = uri.port_u16().unwrap_or(80);
    let uri_host = uri
        .host()
        .ok_or_else(|| "host must be present in URI".to_string())
        .and_then(|host| {
            IpAddr::from_str(host)
                .map_err(|_| "URI host must be valid IPv4/IPv6 address".to_string())
        })
        .expect("HTTP URI not valid");

    SocketAddr::from((uri_host, uri_port))
}

View on GitHub (pinned to bdb87aeaa4)