risingwavelabs/risingwave · error

missing host in jdbc url

Error message

missing host in jdbc url

What it means

`parse_jdbc_url` extracts the host via `Url::host_str()` and bails with 'missing host in jdbc url' when the parsed URL has no host component (e.g. an empty or non-authority form). The postgres connector needs an explicit host to connect.

Solutions

  1. Include an explicit host: `jdbc:postgresql://localhost:5432/mydb`.
  2. If targeting a local instance, use `localhost` or `127.0.0.1` instead of a socket path.
  3. Check for a deleted/empty host segment between `//` and `:` in the URL.
  4. Recreate the sink after fixing the URL.

Example fix

// before
jdbc.url = 'jdbc:postgresql:///mydb'
// after
jdbc.url = 'jdbc:postgresql://localhost:5432/mydb'
Defensive patterns

Strategy: validation

Validate before calling

let stripped = jdbc_url.strip_prefix("jdbc:").unwrap();
assert!(url::Url::parse(stripped).ok().and_then(|u| u.host_str().map(String::from)).is_some());

Prevention

When it happens

Trigger: A sink URL like `jdbc:postgresql:/dbname` or `jdbc:postgresql://:5432/db` (empty host) or a unix-socket-style URL, which yields `None` from `host_str()`.

Common situations: Users adapting JDBC URLs meant for local sockets (`jdbc:postgresql:///db`), or dropping the host while editing config files.

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 risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/2dc720718494a9c3. Report an issue: GitHub.

Appendix: source

Thrown at src/stream/src/from_proto/sink.rs:404

fn parse_jdbc_url(url: &str) -> anyhow::Result<JdbcUrl> {
    if !url.starts_with("jdbc:postgresql") {
        bail!(
            "invalid jdbc url, to switch to postgres rust connector, we need to use the url jdbc:postgresql://..."
        )
    }

    // trim the "jdbc:" prefix to make it a valid url
    let url = url.replace("jdbc:", "");

    // parse the url
    let url = Url::parse(&url).map_err(|e| anyhow!(e).context("failed to parse jdbc url"))?;

    let scheme = url.scheme();
    assert_eq!("postgresql", scheme, "jdbc scheme should be postgresql");
    let host = url
        .host_str()
        .ok_or_else(|| anyhow!("missing host in jdbc url"))?;
    let port = url
        .port()
        .ok_or_else(|| anyhow!("missing port in jdbc url"))?;
    let Some(db_name) = url.path().strip_prefix('/') else {
        bail!("missing db_name in jdbc url");
    };
    let mut username = None;
    let mut password = None;
    for (key, value) in url.query_pairs() {
        if key == "user" {
            username = Some(value.to_string());
        }
        if key == "password" {
            password = Some(value.to_string());
        }
    }

    Ok(JdbcUrl {

View on GitHub (pinned to 6469eb736d)