Sonarr/Sonarr · error · NtfyException

Unable to send text message: {0}

Error message

Unable to send text message: {0}

What it means

NtfyException("Unable to send text message: {0}") is thrown when an HttpException occurs during a single-topic send and the status code is NOT 401 Unauthorized or 403 Forbidden (those are re-thrown unchanged at line 154 so auth errors propagate distinctly). The {0} is filled with ex.Message. This is the general HTTP-failure path for a single ntfy topic publish.

Source

Thrown at src/NzbDrone.Core/Notifications/Ntfy/NtfyProxy.cs:157

                foreach (var header in settings.Headers)
                {
                    requestBuilder.Headers.Add(header.Key, header.Value);
                }

                var request = requestBuilder.Build();

                _httpClient.Execute(request);
            }
            catch (HttpException ex)
            {
                if (ex.Response.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
                {
                    _logger.Error(ex, "Authorization is required");
                    throw;
                }

                throw new NtfyException("Unable to send text message: {0}", ex, ex.Message);
            }
        }
    }
}

View on GitHub (pinned to da2284d7ea)

Solutions

  1. Read the wrapped ex.Message (shown via {0}) to get the ntfy server's specific error text.
  2. Verify settings.ServerUrl is the correct base URL of an ntfy instance (e.g. https://ntfy.sh or https://your-host), with no trailing path.
  3. Confirm the topic name uses only allowed characters (alphanumeric, hyphen, underscore).
  4. For self-hosted servers, check ntfy server logs for the corresponding request error.
  5. For 5xx, retry; check the ntfy server health.
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate server URL and topic before sending
if (settings.ServerUrl.IsNotNullOrWhiteSpace() && !Uri.TryCreate(settings.ServerUrl, UriKind.Absolute, out _))
{
    return new ValidationFailure("ServerUrl", "Ntfy server URL is invalid.");
}

Type guard

public static bool IsNtfyHttp(Exception ex) => ex is Ntfy.NtfyException && !ex.Message.Contains("all topics");

Try / catch

// Auth errors (401/403) propagate as HttpException; other HTTP errors become NtfyException
catch (NtfyException ex)
{
    _logger.Error(ex, "Ntfy send failed: {0}", ex.Message);
    return new ValidationFailure("ServerUrl", ex.Message);
}

Prevention

When it happens

Trigger: The private SendNotification (line 113) executes the HTTP request to {serverUrl}/{topic} and catches HttpException. If the status is anything other than 401/403 (e.g. 404, 405, 422, 500, 502, 503), it wraps the error into NtfyException with the server's message.

Common situations: Self-hosted ntfy server URL is wrong (404). The ntfy server does not allow POST on that path (405). Server-side error (5xx). The ServerUrl points to a path that is not an ntfy instance. Topic name contains invalid path characters. Attachments or priority param malformed.

Related errors


AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13). Data as JSON: /api/errors/b03fabb37343dddb. Report an issue: GitHub.