shadowsocks/shadowsocks-rust · error

failed to create ServerConfig, error: {}

Error message

failed to create ServerConfig, error: {}

What it means

After parsing address and password, create() constructs a ServerConfig with ServerConfig::new(svr_addr, password, method) and panics if construction fails. ServerConfig::new rejects invalid combinations such as unsupported method names or invalid server address types for the method. The embedded `err` carries the precise reason.

Source

Thrown at src/service/local.rs:658

                    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);
                }
            };
            sc.set_source(ServerSource::CommandLine);
            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`")
                        })

View on GitHub (pinned to 8eb0f0a65b)

Solutions

  1. Read the embedded error message for the exact ServerConfig validation failure
  2. Use a valid method name supported by the build (check --help / feature flags)
  3. For 2022 methods, supply a correctly sized base64 key (e.g. openssl rand -base64 32)
  4. Verify the server-addr format: `host:port` or `[ipv6]:port`

Example fix

// before
sslocal --server-addr example.com:8388 --encrypt-method aes-256-gcmv1 --password s3cret
// after
sslocal --server-addr example.com:8388 --encrypt-method aes-256-gcm --password s3cret
Defensive patterns

Strategy: validation

Validate before calling

# pre-validate method/addr before launch:
echo "$METHOD" | grep -Eq '^(aes-128-gcm|aes-256-gcm|chacha20-ietf-poly1305|2022-blake3-aes-256-gcm|none|plain)$' || exit 1

Prevention

When it happens

Trigger: Calling public `create` (from main) while iterating CLI `--server-addr` entries; `ServerConfig::new` returns Err, e.g. because the method string is not a recognized cipher kind or the addr/format is inconsistent with the method (e.g. non-2022 format password for an AEAD-2022 method).

Common situations: Misspelled cipher method (`aes-256-gcm ` with trailing space, `chacha20-ietf-poly1305` unavailable under disabled features); AEAD-2022 methods given a base64 password of wrong length; method names differing between CLI and JSON config syntax.

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


AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09). Data as JSON: /api/errors/77470f81ca008d79. Report an issue: GitHub.