neondatabase/neon · error

Invalid port in {remote_endpoint}

Error message

Invalid port in {remote_endpoint}

What it means

url.port() returned None for the synthetic http:// URL, meaning no explicit port could be derived: either the endpoint omits ':port' entirely ('collector.host.tld') or the port digits are out of the u16 range so URL parsing did not produce a port ('collector.host.tld:90001'). Since http has no default port in url::Url's default-port table here, absence maps to this error rather than 80.

Source

Thrown at compute_tools/src/rsyslog.rs:125

        && url.query().is_none()
        && url.fragment().is_none()
        && url.username() == ""
        && url.password().is_none();

    if !is_valid {
        return Err(anyhow!(
            "Invalid address format {remote_endpoint}, expected host:port"
        ));
    }
    let host = match url.host() {
        Some(Host::Domain(h)) if hostname_validator::is_valid(h) => h.to_string(),
        Some(Host::Ipv4(ip4)) => ip4.to_string(),
        Some(Host::Ipv6(ip6)) => ip6.to_string(),
        _ => return Err(anyhow!("Invalid host")),
    };
    let port = url
        .port()
        .ok_or_else(|| anyhow!("Invalid port in {remote_endpoint}"))?;

    Ok((host, port, tls))
}

fn generate_audit_rsyslog_config(
    log_directory: String,
    endpoint_id: &str,
    project_id: &str,
    remote_syslog_host: &str,
    remote_syslog_port: u16,
    remote_syslog_tls: &str,
) -> String {
    format!(
        include_str!("config_template/compute_audit_rsyslog_template.conf"),
        log_directory = log_directory,
        endpoint_id = endpoint_id,
        project_id = project_id,
        remote_syslog_host = remote_syslog_host,

View on GitHub (pinned to 8f60b04da4)

Solutions

  1. Append an explicit port in 1..=65535, e.g. collector.host.tld:5555
  2. Bracket IPv6 addresses so the trailing :port is unambiguous: [addr]:5555
  3. Double-check for typos like 0-padding or extra digits

Example fix

# before
AUDIT_LOGGING_ENDPOINT=collector.host.tld

# after
AUDIT_LOGGING_ENDPOINT=collector.host.tld:5555
Defensive patterns

Strategy: validation

Validate before calling

// require an explicit, in-range port before configure_audit_rsyslog
let Some((_, port)) = endpoint.rsplit_once(':') else {
    bail!("endpoint {endpoint:?} is missing an explicit :port");
};
let port: u16 = port.parse().map_err(|_| anyhow!("port out of range in {endpoint:?}"))?;

Type guard

fn has_valid_port(endpoint: &str) -> bool {
    endpoint
        .rsplit_once(':')
        .and_then(|(_, p)| p.parse::<u16>().ok())
        .is_some()
}

Try / catch

let port = url
    .port()
    .ok_or_else(|| anyhow!("Invalid port in {remote_endpoint}"))?;

Prevention

When it happens

Trigger: host without port ('collector.host.tld'); port above 65535 or otherwise unparseable ('90001', '5t14'); IPv6 without brackets consuming colons so no port is recognized.

Common situations: Assuming a default syslog port (514) is implied; typos in 6-digit ports; unbracketed IPv6 addresses.

Related errors


AI-assisted analysis of neondatabase/neon@8f60b04da4 (2026-08-16). Data as JSON: /api/errors/7a2c2b7defe4e73e. Report an issue: GitHub.