denoland/deno · error

invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}

Error message

invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}

What it means

The minimal dcore runtime parses --inspect* flags itself: the value must be attached with `=` and must parse as a std SocketAddr, i.e. a literal IP plus port. Hostnames such as `localhost` do not parse as SocketAddr, so `--inspect=localhost:9229` fails with this message wrapping the parse error.

Source

Thrown at libs/dcore/src/main.rs:180

  strace_ops_summary: bool,
  v8_flags: Vec<String>,
}

impl Args {
  /// Returns `Ok(None)` when `--help` was requested (usage already printed).
  fn parse(
    args: impl IntoIterator<Item = String>,
  ) -> Result<Option<Self>, Error> {
    let mut out = Args::default();
    let mut file_path: Option<String> = None;
    let mut seen_inspect_flag: Option<&'static str> = None;

    // `--inspect*` takes its value only via `=` (clap's `require_equals`), so
    // `--inspect 1.2.3.4:9229` treats the address as the positional argument.
    let parse_addr = |flag: &str, value: Option<&str>| match value {
      None => Ok(None),
      Some(v) => v.parse::<SocketAddr>().map(Some).map_err(|e| {
        anyhow::anyhow!("invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}")
      }),
    };

    for arg in args {
      let (name, value) = match arg.split_once('=') {
        Some((name, value)) => (name, Some(value)),
        None => (arg.as_str(), None),
      };
      match name {
        "-h" | "--help" => {
          println!("{USAGE}");
          return Ok(None);
        }
        "--inspect" | "--inspect-brk" | "--inspect-wait" => {
          if let Some(previous) = seen_inspect_flag {
            bail!("the argument '{previous}' cannot be used with '{name}'");
          }
          seen_inspect_flag = Some(match name {

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Use a numeric IP: `--inspect=127.0.0.1:9229` or `--inspect=0.0.0.0:9229`
  2. Bracket IPv6 addresses: `--inspect=[::1]:9229`
  3. Keep the `=` form — with a space the address becomes the positional argument and the flag has no value

Example fix

# before — hostname is not a SocketAddr
dcore --inspect=localhost:9229 main.js

# after — numeric IP, attached with '='
dcore --inspect=127.0.0.1:9229 main.js
Defensive patterns

Strategy: validation

Validate before calling

addr="${INSPECT_ADDR:-127.0.0.1:9229}"
if ! printf '%s' "$addr" | grep -Eqx '(\[?[0-9a-fA-F:.]+\]?)?:?[0-9]+'; then
  echo "inspect address must be IP:PORT (no hostnames): '$addr'"; exit 1
fi
dcore --inspect="$addr" main.js

Type guard

fn valid_inspect_addr(v: &str) -> bool {
  v.parse::<std::net::SocketAddr>().is_ok()
}

Prevention

When it happens

Trigger: Launching dcore with `--inspect=localhost:9229`, a bare port (`--inspect=:9229`), or any non-IP:PORT value; also `--inspect 127.0.0.1:9229` (space form) which treats the address as the positional script argument.

Common situations: Copy-pasting inspector flags from mainline `deno` docs (which resolve hostnames) into dcore; VS Code launch.json configs using localhost; unbracketed IPv6 addresses.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/fd3db2a14b64d5c2. Report an issue: GitHub.