shadowsocks/shadowsocks-rust · error
failed to create ServerConfig, error: {}
Error message
failed to create ServerConfig, error: {} What it means
After parsing the CLI server address, password and method, create() calls shadowsocks-service's ServerConfig::new to validate them; any error it returns (e.g. invalid server address format, method/password combination rejected) is surfaced via this panic. It is a wrapper: the underlying cause is in the `{}` payload.
Source
Thrown at src/service/server.rs:361
if method.is_none() {
// If method doesn't need a key (none, plain), then we can leave it empty
String::new()
} else {
match crate::password::read_server_password(svr_addr) {
Ok(pwd) => pwd,
Err(..) => panic!("`password` is required for server {svr_addr}"),
}
}
}
};
let svr_addr = svr_addr.parse::<ServerAddr>().expect("server-addr");
let timeout = matches.get_one::<u64>("TIMEOUT").map(|x| Duration::from_secs(*x));
let mut sc = match ServerConfig::new(svr_addr, password, method) {
Ok(sc) => sc,
Err(err) => {
panic!("failed to create ServerConfig, error: {}", err);
}
};
if let Some(timeout) = timeout {
sc.set_timeout(timeout);
}
if let Some(p) = matches.get_one::<String>("PLUGIN").cloned() {
let plugin = PluginConfig {
plugin: p,
plugin_opts: matches.get_one::<String>("PLUGIN_OPT").cloned(),
plugin_args: Vec::new(),
plugin_mode: matches
.get_one::<String>("PLUGIN_MODE")
.map(|x| {
x.parse::<Mode>()
.expect("plugin-mode must be one of `tcp_only` (default), `udp_only` and `tcp_and_udp`")
})
.unwrap_or(Mode::TcpOnly),View on GitHub (pinned to 8eb0f0a65b)
Solutions
- Read the inner error text after `error:` — it names the exact validation that failed
- Use a well-formed server address: host:port, or [ipv6]:port e.g. `-s '[::1]:8388'`
- Verify the `--method` and `--password` pair is valid for that cipher (correct key length / encodable password)
- Prefer a JSON config file (`-c config.json`) so validation errors come back as structured LoadConfigFailure instead of CLI panics
Example fix
// before ssserver -s '8388' -m aes-256-gcm -p secret // after ssserver -s '0.0.0.0:8388' -m aes-256-gcm -p secret
Defensive patterns
Strategy: validation
Validate before calling
fn looks_like_host_port(s: &str) -> bool {
if s.starts_with('[') { s.contains("]:") } else { s.rsplit_once(':').map(|(h,p)| !h.is_empty() && p.parse::<u16>().is_ok()).unwrap_or(false) }
}
if !looks_like_host_port(server_addr) { eprintln!("bad -s value: {server_addr}"); std::process::exit(2); } Try / catch
// panic is not catchable in stable Rust; inspect the spawned process stderr:
let out = Command::new("ssserver").args(&args).output()?;
if !out.status.success() { eprintln!("ssserver failed: {}", String::from_utf8_lossy(&out.stderr)); } Prevention
- Use host:port (or [ipv6]:port) form for -s/--server-addr
- Test the full flag set with a dry run or against a JSON config where errors are structured
- Keep cipher method and password from the same validated source
When it happens
Trigger: `--server-addr` fails ServerAddr parsing beyond the earlier expect (bad host/port forms handled by ServerConfig), or ServerConfig::new rejects the (addr, password, method) combination, e.g. a method requiring a key with invalid key material.
Common situations: Malformed `-s` values like `8388` (missing host), IPv6 literals without brackets, or password bytes that fail key derivation constraints for the chosen cipher.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- `password` is required for server {svr_addr}
- failed to create ServerConfig, error: {}
- not supported `protocol` "{p}"
- `local-addr` is required for protocol {}
- `password` is required for server {svr_addr}
AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09).
Data as JSON: /api/errors/2e90afae689ed682.
Report an issue: GitHub.