shadowsocks/shadowsocks-windows · warning · ArgumentException
Port out of range
Error message
Port out of range
What it means
ArgumentException thrown by CheckPort when a port is <= 0 or > 65535. Valid TCP/UDP ports are 1..65535. This is part of the server-config validation flow (also reached via CheckLocalPort) used when loading or saving a Shadowsocks server entry.
Source
Thrown at shadowsocks-csharp/Model/Configuration.cs:355
config.configs.Insert(index.GetValueOrDefault(config.configs.Count), server);
//if (index.HasValue)
// config.configs.Insert(index.Value, server);
//else
// config.configs.Add(server);
}
return server;
}
public static Server GetDefaultServer()
{
return new Server();
}
public static void CheckPort(int port)
{
if (port <= 0 || port > 65535)
throw new ArgumentException(I18N.GetString("Port out of range"));
}
public static void CheckLocalPort(int port)
{
CheckPort(port);
if (port == 8123)
throw new ArgumentException(I18N.GetString("Port can't be 8123"));
}
private static void CheckPassword(string password)
{
if (string.IsNullOrEmpty(password))
throw new ArgumentException(I18N.GetString("Password can not be blank"));
}
public static void CheckServer(string server)
{
if (string.IsNullOrEmpty(server))
View on GitHub (pinned to 891d971682)
Solutions
- Set the port to a value in 1..65535, preferring the non-privileged range 1024..65535.
- Re-open the config dialog and correct the entry, then save.
- Manually fix the server_port field in gui-config.json and reload.
Example fix
// before Configuration.CheckPort(70000); // throws // after int port = 70000; if (port < 1 || port > 65535) port = 8388; // sane default Configuration.CheckPort(port);
Defensive patterns
Strategy: validation
Validate before calling
static bool IsValidPort(int p) => p > 0 && p <= 65535;
if (!IsValidPort(port)) {
// reject in the UI before calling CheckPort
return;
} Try / catch
try { Configuration.CheckPort(port); }
catch (ArgumentException ex) { /* show ex.Message in the UI, keep the dialog open */ } Prevention
- Clamp port input in the GUI to 1..65535.
- Validate gui-config.json on load and reject out-of-range values.
When it happens
Trigger: A user enters 0, a negative number, or a value above 65535 in the server config dialog. gui-config.json is hand-edited with an out-of-range server_port. An int parse of an oversized port string overflows the valid range.
Common situations: Typo such as 65536 or 808080. Port field left blank (parsed as 0). Copy-paste of a port that included extra digits.
Related errors
- Port can't be 8123
- Server IP can not be blank
- Unknown forward proxy.
- Password can not be blank
- Timeout is invalid, it should not exceed {0}
AI-assisted analysis of shadowsocks/shadowsocks-windows@891d971682 (2026-08-13).
Data as JSON: /api/errors/39b2538713ac86d5.
Report an issue: GitHub.