tinyhumansai/openhuman · error
invalid --port: {e}
Error message
invalid --port: {e} What it means
The token after `--port` failed to parse as u16. Because this parser consumes the next token unconditionally, the failure covers three shapes: non-numeric text, a number outside 0–65535, and a swallowed flag (`--port --host x` makes '--host' the value). An empty quoted value ('') also parses to nothing and lands here.
Source
Thrown at src/core/cli.rs:377
fn run_server_command(args: &[String]) -> Result<()> {
let mut port: Option<u16> = None;
let mut host: Option<String> = None;
let mut socketio_enabled = true;
let mut headless_api = false;
let mut verbose = false;
let log_scope = CliLogDefault::Global;
let mut i = 0usize;
// Manual argument parsing loop for specific flags.
while i < args.len() {
match args[i].as_str() {
"--port" => {
let raw = args
.get(i + 1)
.ok_or_else(|| anyhow::anyhow!("missing value for --port"))?;
port = Some(
raw.parse::<u16>()
.map_err(|e| anyhow::anyhow!("invalid --port: {e}"))?,
);
i += 2;
}
"--host" => {
host = Some(
args.get(i + 1)
.ok_or_else(|| anyhow::anyhow!("missing value for --host"))?
.clone(),
);
i += 2;
}
"--jsonrpc-only" => {
socketio_enabled = false;
i += 1;
}
"--headless-api" => {
socketio_enabled = false;
headless_api = true;View on GitHub (pinned to a221052e0d)
Solutions
- Use an integer in 0–65535: `openhuman run --port 7788`
- Validate/normalize the variable before use: `PORT=${PORT:-7788}` and check it is numeric
- Omit the flag to fall back to the default 7788 or OPENHUMAN_CORE_PORT
Example fix
# before (PORT unset -> empty string)
openhuman run --port "$PORT"
# after
PORT="${PORT:-7788}"
openhuman run --port "$PORT" Defensive patterns
Strategy: validation
Validate before calling
# bash: validate u16 shape and range before passing it on
PORT="${PORT:-7788}"
if ! [[ "$PORT" =~ ^[0-9]+$ ]] || (( PORT < 0 || PORT > 65535 )); then
echo "invalid port: $PORT (expected 0-65535)" >&2; exit 2
fi
openhuman run --port "$PORT" Type guard
// Rust wrapper: narrow to u16 before formatting the CLI arg
fn valid_port(s: &str) -> Option<u16> { s.trim().parse::<u16>().ok() } Prevention
- Never pass a flag-looking token after --port — it gets consumed as the value and fails the u16 parse
- Default empty variables: PORT=${PORT:-7788} before interpolation
- Remember the valid range is exactly 0–65535 (u16); 70000 fails
When it happens
Trigger: `--port abc`; `--port 70000` (above u16 range); `--port --host 0.0.0.0` (flag consumed as value); `--port ""` from an unset env variable expansion.
Common situations: `--port "$PORT"` with PORT unset or non-numeric; forwarding a container/CI port variable with a different range convention; placeholder text like `<port>` left in the command.
Related errors
- missing value for --port
- missing value for --host
- unknown run arg: {other}
- audio blob is empty
- voice_not_compiled
AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16).
Data as JSON: /api/errors/88812dfdec27fc8b.
Report an issue: GitHub.