denoland/deno · error
invalid socket address
Error message
invalid socket address
What it means
connect_to_socket() in ext/cron/socket.rs accepts exactly three address forms: 'tcp:<addr>', 'unix:<path>' (non-Windows builds), and 'vsock:<cid>:<port>' (linux/android/macos builds). Any other value — unknown scheme, missing scheme, or a scheme compiled out for the platform — falls through to the catch-all arm and returns io::ErrorKind::InvalidInput 'invalid socket address'. The address comes from DENO_UNSTABLE_CRON_SOCK.
Source
Thrown at ext/cron/socket.rs:407
std::io::ErrorKind::InvalidInput,
"invalid vsock cid",
)
})?
};
let port = port.parse().map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid vsock port",
)
})?;
let stream = tokio::time::timeout(
std::time::Duration::from_secs(5),
VsockStream::connect(VsockAddr::new(cid, port)),
)
.await??;
Ok(SocketStream::Vsock(stream))
}
_ => Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"invalid socket address",
)),
}
}
async fn register_cron(
socket_writer: &mut BufWriter<impl tokio::io::AsyncWrite + Unpin>,
spec: &CronSpec,
) -> Result<(), std::io::Error> {
let cron = CronRegistration {
name: &spec.name,
schedule: &spec.cron_schedule,
backoff_schedule: spec.backoff_schedule.as_deref(),
};
let msg = OutboundMessage::Register { crons: &[cron] };
View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Prefix the address with a supported scheme: 'tcp:127.0.0.1:5000'
- Use 'unix:/path/to/socket' for Unix domain sockets (not available on Windows)
- Use 'vsock:cid:port' for AF_VSOCK schedulers on linux/android/macos
- Leave DENO_UNSTABLE_CRON_SOCK unset to use the built-in local cron handler
Example fix
# before DENO_UNSTABLE_CRON_SOCK='localhost:5000' deno run app.ts # Error: invalid socket address # after DENO_UNSTABLE_CRON_SOCK='tcp:localhost:5000' deno run app.ts
Defensive patterns
Strategy: validation
Validate before calling
const addr = Deno.env.get('DENO_UNSTABLE_CRON_SOCK')?.trim() ?? '';
const okSchemes = /^(tcp:|unix:|vsock:)/;
if (addr && !okSchemes.test(addr)) {
throw new Error(
`Unsupported cron socket address '${addr}'; expected tcp:host:port, unix:/path, or vsock:cid:port`,
);
}
if (addr.startsWith('unix:') && Deno.build.os === 'windows') {
throw new Error('unix: cron sockets are not supported on Windows');
} Prevention
- Always include a scheme prefix in DENO_UNSTABLE_CRON_SOCK
- Check scheme availability per platform (unix: is not compiled on Windows)
- Leave the variable unset unless an external cron scheduler is actually in use
When it happens
Trigger: DENO_UNSTABLE_CRON_SOCK='localhost:5000' (no tcp: prefix), 'udp:127.0.0.1:53' (unsupported scheme), 'http://sched:5000', '' (empty string), 'tcp' with no colon at all, or 'unix:/tmp/cron.sock' on Windows where the unix arm is not compiled in.
Common situations: Assuming the variable takes a plain host:port; forgetting the scheme prefix; attempting a Unix-domain-socket scheduler on a Windows host; copy-pasting a URL instead of a socket address.
Related errors
- invalid vsock cid
- invalid vsock port
- Can't convert url ("{}") to filename.
- Can't convert url ("{}") to filename.
- invalid value '{v}' for '{flag}=<HOST_AND_PORT>': {e}
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/5b0f76f5c8b7f495.
Report an issue: GitHub.