louislam/uptime-kuma · error · Error
Invalid service name. Please use the internal Service Name (
Error message
Invalid service name. Please use the internal Service Name (no spaces).
What it means
Thrown by Monitor.validate() when a "system-service" monitor's system_service_name contains characters outside the set [a-zA-Z0-9._\-@]. This guards the value because it is passed to the service manager; spaces, slashes, shell metacharacters, or unicode break the lookup and risk injection.
Source
Thrown at server/model/monitor.js:1702
if (this.accepted_statuscodes_json) {
try {
JSON.parse(this.accepted_statuscodes_json);
} catch (e) {
throw new Error(`Accepted status codes must be valid JSON: ${e.message}`);
}
}
if (["system-service", "pm2"].includes(this.type)) {
this.system_service_name = (this.system_service_name || "").trim();
if (!this.system_service_name) {
throw new Error(this.type === "pm2" ? "PM2 process name is required." : "Service Name is required.");
}
}
if (this.type === "system-service" && !/^[a-zA-Z0-9._\-@]+$/.test(this.system_service_name)) {
throw new Error("Invalid service name. Please use the internal Service Name (no spaces).");
}
if (this.type === "pm2" && /[\u0000-\u001F\u007F]/.test(this.system_service_name)) {
throw new Error("Invalid PM2 process name.");
}
if (this.type === "ping") {
// ping parameters validation
if (this.packetSize && (this.packetSize < PING_PACKET_SIZE_MIN || this.packetSize > PING_PACKET_SIZE_MAX)) {
throw new Error(
`Packet size must be between ${PING_PACKET_SIZE_MIN} and ${PING_PACKET_SIZE_MAX} (default: ${PING_PACKET_SIZE_DEFAULT})`
);
}
if (
this.ping_per_request_timeout &&
(this.ping_per_request_timeout < PING_PER_REQUEST_TIMEOUT_MIN ||
this.ping_per_request_timeout > PING_PER_REQUEST_TIMEOUT_MAX)View on GitHub (pinned to 6b5ea01557)
Solutions
- Use the internal service unit name reported by `systemctl list-units --type=service`, e.g. "nginx.service".
- Strip spaces and shell metacharacters from the value before saving.
- If the name legitimately needs a disallowed character, alias/wrap the service so its unit name matches the allowed set.
Example fix
// before
{ type: "system-service", system_service_name: "Web Server (prod)" }
// after
{ type: "system-service", system_service_name: "nginx.service" } Defensive patterns
Strategy: validation
Validate before calling
const SERVICE_NAME_RE = /^[a-zA-Z0-9._\-@]+$/;
function validServiceName(name) {
return typeof name === "string" && SERVICE_NAME_RE.test(name);
} Type guard
function isAllowedServiceName(name) {
return typeof name === "string" && /^[a-zA-Z0-9._\-@]+$/.test(name);
} Try / catch
try {
await bean.validate();
} catch (e) {
if (/Invalid service name/.test(e.message)) {
return badRequest("Use the internal service unit name (no spaces)");
}
throw e;
} Prevention
- Surface the allowed character set in the UI hint next to the field.
- Resolve unit names from `systemctl list-units` rather than free-text entry.
When it happens
Trigger: Save a system-service monitor whose name fails /^[a-zA-Z0-9._\-@]+$/. Common failing inputs: "nginx service" (space), "nginx.service " (trailing space is trimmed, but other whitespace mid-string fails), "user@host:80" (colon not allowed), names with "/" or "%".
Common situations: User enters the human-readable display name ("Web Server") instead of the internal unit name ("nginx.service"). Copying a value from a URL or path that contains disallowed characters. Locale-specific unicode in service names.
Related errors
- Service Name is required.
- Invalid PM2 process name.
- Packet size must be between ${PING_PACKET_SIZE_MIN} and ${PI
- Per-ping timeout must be between ${PING_PER_REQUEST_TIMEOUT_
- Echo requests count must be between ${PING_COUNT_MIN} and ${
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/66157c5e22a15111.
Report an issue: GitHub.