Kareadita/Kavita · error · KavitaException
ip-address-invalid
ip-address-invalid
Error message
ip-address-invalid
What it means
Thrown by SettingsService when updating ServerSettingKey.IpAddresses and one of the comma-separated values fails IPAddress.TryParse. Kavita binds the server to these addresses, so each must be a valid IPv4/IPv6 literal. Note: under Docker (OsInfo.IsDocker) the check is skipped because IP binding is managed by the container runtime.
Source
Thrown at Kavita.Services/SettingsService.cs:350
unitOfWork.SettingsRepository.Update(setting);
}
updateTask = updateTask || UpdateSchedulingSettings(setting, updateSettingsDto);
UpdateEmailSettings(setting, updateSettingsDto);
updatedOidcSettings = await UpdateOidcSettings(setting, updateSettingsDto) || updatedOidcSettings;
if (setting.Key == ServerSettingKey.IpAddresses && updateSettingsDto.IpAddresses != setting.Value)
{
if (OsInfo.IsDocker) continue;
// Validate IP addresses
foreach (var ipAddress in updateSettingsDto.IpAddresses.Split(',',
StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
{
if (!IPAddress.TryParse(ipAddress.Trim(), out _))
{
throw new KavitaException("ip-address-invalid");
}
}
setting.Value = updateSettingsDto.IpAddresses;
// IpAddresses is managed in appSetting.json
Configuration.IpAddresses = updateSettingsDto.IpAddresses;
unitOfWork.SettingsRepository.Update(setting);
}
if (setting.Key == ServerSettingKey.BaseUrl && updateSettingsDto.BaseUrl + string.Empty != setting.Value)
{
var path = !updateSettingsDto.BaseUrl.StartsWith('/')
? $"/{updateSettingsDto.BaseUrl}"
: updateSettingsDto.BaseUrl;
path = !path.EndsWith('/')
? $"{path}/"
: path;
setting.Value = path;View on GitHub (pinned to 9c3e540000)
Solutions
- Enter only valid IPv4/IPv6 literals separated by commas, e.g. '127.0.0.1, ::1'.
- Use 'localhost' only if you mean loopback - prefer '127.0.0.1' since the validator wants an IP literal.
- Remove CIDR masks; Kavita binds addresses, not ranges.
- If running in Docker, set bind addresses via the container/port config instead of this setting.
Example fix
// before updateSettingsDto.IpAddresses = "127.0.0.1, localhost, ::1"; await settingsService.UpdateSettings(updateSettingsDto); // after updateSettingsDto.IpAddresses = "127.0.0.1, ::1"; await settingsService.UpdateSettings(updateSettingsDto);
Defensive patterns
Strategy: validation
Validate before calling
var ips = updateSettingsDto.IpAddresses.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (ips.Any(ip => !IPAddress.TryParse(ip, out _)))
return BadRequest("ip-address-invalid");
await settingsService.UpdateSettings(updateSettingsDto); Type guard
static bool AllValidIps(string csv) => csv.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
.All(ip => IPAddress.TryParse(ip, out _)); Prevention
- Enter only IPv4/IPv6 literals separated by commas.
- Avoid hostnames, CIDR notation, and trailing junk.
- Under Docker, set bind addresses via container config, not this setting.
When it happens
Trigger: Saving server settings with an IpAddresses string like '127.0.0.1, notanip, ::1' where one token is not a parseable IP address; the loop parses each comma-separated entry and throws on the first invalid one.
Common situations: Typo in the IP field ('1.2.3'); entering a hostname instead of an IP ('localhost'); trailing junk after an address; or copying a CIDR notation ('10.0.0.0/24') which TryParse rejects.
Related errors
- bookmark-dir-permissions
- oidc-invalid-authority
- errors.oidc.failed-to-update-email
- errors.import-fields.non-unique-age-ratings
- errors.import-fields.non-unique-fields
AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13).
Data as JSON: /api/errors/8c2ee7075b86cb85.
Report an issue: GitHub.