shadowsocks/shadowsocks-rust · error
missing `manager_port`
Error message
missing `manager_port`
What it means
When the config is a manager-server config and no unix-domain-socket address is available (non-unix builds or absent socket path), the code requires an explicit TCP manager_port. If the address matches a host-only form and the port portion is missing on a non-unix platform, it returns ErrorKind::MissingField with 'missing `manager_port`'.
Source
Thrown at crates/shadowsocks-service/src/config.rs:2476
}
// Manager Address
if let Some(ma) = config.manager_address {
let manager = match config.manager_port {
Some(port) => {
match ma.parse::<IpAddr>() {
Ok(ip) => ManagerAddr::from(SocketAddr::new(ip, port)),
Err(..) => {
// treated as domain
ManagerAddr::from((ma, port))
}
}
}
#[cfg(unix)]
None => ManagerAddr::from(PathBuf::from(ma)),
#[cfg(not(unix))]
None => {
let e = Error::new(ErrorKind::MissingField, "missing `manager_port`", None);
return Err(e);
}
};
let mut manager_config = ManagerConfig::new(manager);
manager_config.mode = global_mode;
if let Some(ref m) = config.method {
match m.parse::<CipherKind>() {
Ok(method) => manager_config.method = Some(method),
Err(..) => {
let err = Error::new(
ErrorKind::Invalid,
"unsupported method",
Some(format!("`{m}` is not a supported method")),
);
return Err(err);
}View on GitHub (pinned to 8eb0f0a65b)
Solutions
- Add a `manager_port` field to the config
- Include the port in the manager address, e.g. `127.0.0.1:8787`
- Run on unix and use a unix domain socket path for manager_addr instead
Example fix
// before
{"manager_addr": "127.0.0.1"}
// after
{"manager_addr": "127.0.0.1", "manager_port": 8787} Defensive patterns
Strategy: validation
Validate before calling
fn validate_manager_cfg(cfg: &serde_json::Value) -> Result<(), String> {
let addr = cfg["manager_addr"].as_str().unwrap_or("");
let has_port = addr.rsplit(':').next().map_or(false, |p| p.parse::<u16>().is_ok());
if !has_port && cfg.get("manager_port").is_none() {
return Err("manager config requires manager_port on non-unix".into());
}
Ok(())
} Type guard
fn has_manager_port(cfg: &serde_json::Value) -> bool {
cfg.get("manager_port").and_then(|v| v.as_u64()).map_or(false, |p| p > 0 && p <= 65535)
} Try / catch
match load_manager_config() {
Ok(c) => run(c),
Err(e) if e.to_string().contains("missing `manager_port`") => {
eprintln!("add manager_port to config: {e}");
}
Err(e) => return Err(e),
} Prevention
- Always pair manager_addr with manager_port in portable configs
- Include host:port in the manager address itself
- Don't rely on unix-socket fallback when configs must run cross-platform
When it happens
Trigger: Loading a manager config whose manager address parses to a bare host without a port, on a non-unix target (no PathBuf fallback), so no usable ManagerAddr can be constructed.
Common situations: Writing `"manager_addr": "127.0.0.1"` without `"manager_port"` in the JSON config on Windows/macOS-less non-unix builds; copying a unix config that relies on a socket path onto a non-unix host.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- missing `manager_addr` and `manager_port` in configuration
- missing `local_dns_addr` or `remote_dns_addr` in configurati
- missing `forward_addr` in configuration
- missing `local_port`
- `protocol` invalid
AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09).
Data as JSON: /api/errors/b74daa304287dac4.
Report an issue: GitHub.