Skip to content

Self-hosted ntfy: push infrastructure alerts to your phone

Run a self-hosted ntfy server for push notifications: server.yml essentials behind a TLS proxy, per-topic ACLs with ntfy user and ntfy access, publishing from curl, and wiring Alertmanager and systemd OnFailure to page your phone.

You want an alert on your phone when a disk fills or a service dies, and you do not want that alert to travel through somebody else’s SaaS. ntfy is the smallest honest answer: one Go binary, one YAML file, HTTP POST to publish, and native apps on Android, iOS, and the web that subscribe over a long-lived connection. This guide sets up a server you own, locks it down so your topics are not readable by the whole internet, and wires three real senders into it — Prometheus Alertmanager, a systemd OnFailure= unit that fires whenever any service fails, and plain curl from a cron job.

What you’ll accomplish

  • Run ntfy as a systemd service on your own host, reachable at an HTTPS name through a reverse proxy that does not break its streaming connections.
  • Turn off anonymous access entirely with auth-default-access: deny, then hand out read and write per user, per topic.
  • Publish messages with a title, priority, tags, and a tap-through link, authenticated by an access token rather than a password.
  • Get paged automatically when any systemd unit enters a failed state, without adding a line to that unit’s own file.
  • Receive Alertmanager notifications on the same server, and know exactly what mobile push does and does not do on a self-hosted instance.

Prerequisites

  • A small Linux host — 1 vCPU and 512 MB of RAM is enough for a personal or small-team instance. ntfy 2.x is what this guide targets; every flag and config key used here exists in the 2.x series.
  • A DNS name pointing at that host, and a TLS certificate for it. This guide assumes nginx terminates TLS at ntfy.example.com and ntfy listens only on loopback. Do not skip the TLS part: you will be sending bearer tokens over this connection.
  • root or sudo on the host, and on any machine you want to page you.
  • Prometheus and Alertmanager already running, if you want the webhook receiver step. Our Alertmanager routing and receivers guide covers the routing tree this plugs into.

One thing to be honest about before you start: mobile push behaves differently on the two platforms. The Android app can hold a direct connection to your own server, so a self-hosted instance delivers to Android with no third party involved. iOS cannot — background delivery on iOS requires Apple’s push service, and the certificates for that belong to the published ntfy app, not to your server. The documented workaround is the upstream-base-url setting: your server forwards a small poll request to ntfy.sh, ntfy.sh sends the iOS device a content-free wake-up, and the device then fetches the actual message body from your server. The message contents still come from you; what goes upstream is the fact that something arrived. If that trade is unacceptable, iOS will only show notifications while the app is in the foreground.

How it works

ntfy is a pub/sub broker with an unusually small surface. A publisher does an HTTP POST to https://your-server/<topic> with the message as the request body; metadata like the title and priority ride along as request headers or query parameters. A subscriber holds open a GET on the same path and receives messages as they land. There is no queue to declare and no schema to register — a topic exists the moment somebody publishes to it.

Diagram showing Alertmanager, a systemd OnFailure unit, and cron scripts publishing to topics on a self-hosted ntfy server with per-topic ACLs, which streams to an Android phone, an iOS phone, and desktop subscribers

That simplicity is also the trap. Because topics are created implicitly, an unauthenticated ntfy server treats every topic name as a public URL: anyone who guesses or overhears alerts-prod can read your alerts, and can publish fake ones into them. Obscure topic names are not a control. The fix is to flip the default from allow to deny once, at the server level, and then grant access explicitly.

Step-by-step

1. Install the server. The maintainer publishes an apt repository; there are .rpm packages and static binaries for everything else.

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://archive.heckel.io/apt/pubkey.txt | sudo gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main" | sudo tee /etc/apt/sources.list.d/archive.heckel.io.list
sudo apt update && sudo apt install ntfy
ntfy version
ntfy 2.11.0 (v2.11.0/8a6b1c2, runtime go1.22.3, built 2026-05-14T09:12:44Z)

2. Write server.yml. The packaged config at /etc/ntfy/server.yml is almost entirely commented out. Replace it with the handful of keys that actually matter.

base-url: "https://ntfy.example.com"
listen-http: "127.0.0.1:2586"
behind-proxy: true

cache-file: "/var/lib/ntfy/cache.db"
cache-duration: "12h"

auth-file: "/var/lib/ntfy/user.db"
auth-default-access: "deny"

upstream-base-url: "https://ntfy.sh"
keepalive-interval: "45s"

Four of those deserve a sentence each. base-url must match the public HTTPS name exactly, because ntfy embeds it in the web app and in attachment links. listen-http on loopback keeps the plaintext port off the network. cache-file is the difference between a message store and a fan-out relay — without it, ntfy holds nothing, and a phone that was offline when the alert fired never sees it. behind-proxy tells ntfy to trust X-Forwarded-For for rate limiting, which is what makes per-visitor limits meaningful behind nginx.

3. Put a reverse proxy in front of it. The buffering directives are not optional decoration — subscribers hold a response open for minutes at a time, and nginx’s default buffering will sit on that stream.

server {
  listen 443 ssl;
  http2 on;
  server_name ntfy.example.com;

  ssl_certificate     /etc/letsencrypt/live/ntfy.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/ntfy.example.com/privkey.pem;

  client_max_body_size 20M;

  location / {
    proxy_pass http://127.0.0.1:2586;
    proxy_http_version 1.1;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Connection "";

    proxy_redirect off;
    proxy_buffering off;
    proxy_request_buffering off;
    proxy_read_timeout 3m;
    proxy_send_timeout 3m;
  }
}
sudo nginx -t && sudo systemctl reload nginx
nginx: configuration file /etc/nginx/nginx.conf test is successful

4. Start ntfy and confirm the config took. The package ships a unit already.

sudo systemctl enable --now ntfy
sudo systemctl is-active ntfy
curl -sS https://ntfy.example.com/v1/health
active
{"healthy":true}

5. Create users. ntfy has three roles that matter: admin (everything), user (nothing unless granted), and the implicit anonymous visitor, which auth-default-access: deny has just cut off. Create one admin for yourself, one account per human who subscribes, and one per machine that publishes.

sudo ntfy user add --role=admin ops
sudo ntfy user add alertbot
sudo ntfy user add phone-hl
sudo ntfy user list
user ops (role: admin, tier: none)
- read-write access to all topics (admin role)
user alertbot (role: user, tier: none)
- no topic-specific permissions
- no access to any (other) topics
user phone-hl (role: user, tier: none)
- no topic-specific permissions
- no access to any (other) topics

6. Grant per-topic access. ntfy access <user> <topic> <permission> is the whole authorization model. Permissions are read-write, read-only, write-only, and deny.

sudo ntfy access alertbot alerts-prod write-only
sudo ntfy access alertbot host-failures write-only
sudo ntfy access phone-hl "alerts-*" read-only
sudo ntfy access phone-hl host-failures read-only
sudo ntfy access phone-hl
user phone-hl (role: user, tier: none)
- read-only access to topic alerts-*
- read-only access to topic host-failures
- no access to any (other) topics

Note the wildcard. A publisher that only ever writes should hold write-only, so a leaked token on a monitoring host cannot be used to read back what everybody else has been alerted about.

7. Issue an access token instead of shipping a password. Tokens are revocable one at a time, which passwords are not.

sudo ntfy token add --expires=never alertbot
token tk_ag3fq7mVBoFD37zQVN29RhuMzNIz2 created for user alertbot, never expires

8. Publish from curl. The body is the message; everything else is a header. Priority accepts min, low, default, high, urgent (or 1 through 5) — urgent is the one that overrides a phone’s silent mode. Tags maps known emoji shortcodes to an icon and shows the rest as plain text. Click is where tapping the notification takes you.

curl -sS \
  -H "Authorization: Bearer tk_ag3fq7mVBoFD37zQVN29RhuMzNIz2" \
  -H "Title: Disk 88% on db-01" \
  -H "Priority: high" \
  -H "Tags: warning,floppy_disk" \
  -H "Click: https://grafana.example.com/d/node/node-exporter" \
  -d "/var is at 88 percent and climbing about 2 points per day." \
  https://ntfy.example.com/alerts-prod
{"id":"kM3T9Zx1QaLb","time":1785974400,"expires":1786017600,"event":"message","topic":"alerts-prod","title":"Disk 88% on db-01","message":"/var is at 88 percent and climbing about 2 points per day.","priority":4,"tags":["warning","floppy_disk"],"click":"https://grafana.example.com/d/node/node-exporter"}

A JSON object with an id means the server accepted and stored it. Every one of those headers has a query-parameter equivalent (?title=, ?priority=, ?tags=, ?click=), which matters for senders that cannot set headers.

9. Wire Alertmanager as a webhook receiver. Alertmanager posts its own JSON document and offers no way to add arbitrary headers, so the metadata goes in the query string.

receivers:
  - name: 'ntfy-prod'
    webhook_configs:
      - url: 'https://ntfy.example.com/alerts-prod?title=Alertmanager&priority=high&tags=rotating_light'
        send_resolved: true
        http_config:
          authorization:
            type: Bearer
            credentials: 'tk_ag3fq7mVBoFD37zQVN29RhuMzNIz2'
amtool check-config /etc/alertmanager/alertmanager.yml
Checking '/etc/alertmanager/alertmanager.yml'  SUCCESS
Found:
 - global config
 - route
 - 0 inhibit rules
 - 2 receivers
 - 0 templates

Out of the box the notification body will be Alertmanager’s raw JSON, which is legible but ugly on a phone screen. Recent ntfy releases include message templating that renders a webhook body into a readable title and message — check the publishing page of the docs for the exact syntax your version supports, and see the troubleshooting section below for the version-independent fallback.

10. Page yourself when any systemd unit fails. Create one template unit that does the publishing, and reference it from OnFailure=.

printf 'NTFY_TOKEN=tk_ag3fq7mVBoFD37zQVN29RhuMzNIz2\n' | sudo tee /etc/ntfy-alert.env >/dev/null
sudo chmod 600 /etc/ntfy-alert.env
[Unit]
Description=Push a ntfy alert for failed unit %i

[Service]
Type=oneshot
EnvironmentFile=/etc/ntfy-alert.env
ExecStart=/usr/bin/curl -sS --max-time 20 \
  -H "Authorization: Bearer ${NTFY_TOKEN}" \
  -H "Title: %i failed on %H" \
  -H "Priority: urgent" \
  -H "Tags: rotating_light" \
  -d "Unit %i entered a failed state. Run: journalctl -u %i -n 50 --no-pager" \
  https://ntfy.example.com/host-failures

Save that as /etc/systemd/system/ntfy-failure@.service, then attach it to a unit with a drop-in rather than editing the unit itself:

sudo systemctl daemon-reload
sudo systemctl edit myapp.service
[Unit]
OnFailure=ntfy-failure@%n.service

The doubled suffix in the resulting unit name — ntfy-failure@myapp.service.service — looks like a typo and is not. %n expands to the full unit name including .service, and that whole string becomes the template instance. Resist the temptation to apply this globally through /etc/systemd/system/service.d/: the drop-in would also apply to the notifier, and a notifier that fails would then try to notify about itself.

11. Subscribe. On Android, install the app, open Settings → General → Default server, set it to https://ntfy.example.com, then add the topic and enter the phone-hl credentials when prompted. On iOS the flow is the same, and the upstream-base-url line from step 2 is what makes background delivery work. On desktop, the web app is served at your own base-url — log in there and subscribe in the browser. For a terminal or a script, the CLI subscribes and pipes each message to a command:

export NTFY_USER=phone-hl
ntfy subscribe --user "$NTFY_USER" https://ntfy.example.com/alerts-prod
{"id":"kM3T9Zx1QaLb","time":1785974400,"event":"message","topic":"alerts-prod","title":"Disk 88% on db-01","message":"/var is at 88 percent and climbing about 2 points per day."}

Validate it works

Prove the deny default first, because everything else depends on it. An unauthenticated read must be refused:

curl -sS -o /dev/null -w '%{http_code}\n' https://ntfy.example.com/alerts-prod/json?poll=1
403

Then confirm an authorized subscriber gets a message end to end. Leave the phone app open on the topic and publish:

curl -sS -u phone-hl -d "end-to-end test $(date -Is)" \
  https://ntfy.example.com/alerts-prod

The device should buzz within a second or two. If it does, disconnect the phone from the network, publish again, reconnect, and check that the message still arrives — that is the test of cache-file, and it is the one people skip.

Finally, prove the OnFailure= path with a unit built to fail:

printf '[Unit]\nDescription=Deliberate failure test\nOnFailure=ntfy-failure@%%n.service\n\n[Service]\nType=oneshot\nExecStart=/bin/false\n' | sudo tee /etc/systemd/system/failtest.service >/dev/null
sudo systemctl daemon-reload
sudo systemctl start failtest.service
Job for failtest.service failed because the control process exited with error code.
systemctl status 'ntfy-failure@failtest.service.service' --no-pager -n 3
ntfy-failure@failtest.service.service - Push a ntfy alert for failed unit failtest.service
     Loaded: loaded (/etc/systemd/system/ntfy-failure@.service; static)
     Active: inactive (dead)

A clean inactive (dead) after a oneshot means curl exited zero. Delete failtest.service when you are done.

Troubleshooting

Everything returns 403 right after you set auth-default-access: deny. That is the setting working. Two follow-ups are usually needed: the change requires a systemctl restart ntfy to take effect, and every existing subscriber — phone apps included — now needs credentials attached to its subscription. Confirm the grant with ntfy access <user> before blaming the client; a write-only user reading a topic gets the same 403 as an anonymous one.

Notifications arrive in bursts of five minutes instead of instantly. The reverse proxy is buffering the subscribe stream. Check that proxy_buffering off and proxy_http_version 1.1 are both present, and that proxy_read_timeout is generous. On Apache the equivalent is SetEnv proxy-sendchunked with the timeout raised; on Cloudflare, note that a proxied orange-cloud record will terminate idle streams on its own schedule regardless of what your origin does.

Nothing arrives on iOS. Work through it in order: the app is subscribed while in the foreground (if not, it is credentials or the topic name), then base-url matches the public HTTPS name character for character, then upstream-base-url: https://ntfy.sh is set and ntfy has been restarted since. Without that last line there is no mechanism to wake a backgrounded iOS app. Also check Priority — min and low messages are deliberately delivered without a sound or banner.

A message published while a device was offline never shows up. cache-file is unset, pointing at a path the ntfy user cannot write, or cache-duration has expired the message. Also check the publisher: a request sent with Cache: no is delivered only to whoever is connected at that instant, by design. Verify with curl -u ops https://ntfy.example.com/alerts-prod/json?poll=1, which replays the cache rather than streaming.

Alertmanager notifications are an unreadable wall of JSON. The version-independent fix is to stop asking ntfy to format Alertmanager’s payload. Point Alertmanager at a receiver you control — a webhook script, or a rule-level annotation pipeline — and have it publish a one-line summary to ntfy with curl and a proper Title header. Getting the alert text right is upstream work anyway; the phone can only render what the rule already says.

The OnFailure= unit never runs. Two usual causes: systemctl daemon-reload was not run after adding the template, or the failing unit has Restart=on-failure set, in which case systemd retries rather than entering failed until the start-limit burst is exhausted. Check with systemctl show myapp.service -p OnFailure — an empty value means the drop-in did not land.

When this is the wrong approach

ntfy is a notification transport. It is not an on-call system, and treating it like one is how alerts get missed. There is no rotation, so the message goes to whoever subscribed rather than to whoever is on duty tonight. There is no escalation, so an alert nobody opens at 03:00 simply sits there. There is no acknowledgement, so two people will both start debugging the same outage, and nobody can prove afterwards that anyone was reached. If those properties matter — and for anything with a customer-facing commitment attached, they do — you need a paging product or a staffed rota, with ntfy at most as one delivery channel underneath it.

It is also the wrong tool for status pages and for anything a non-technical audience reads. Subscribing means installing an app and entering credentials for a server they have never heard of. For “is the site up”, a hosted check with a public status page fits better; our Uptime Kuma deployment guide covers that side, and Uptime Kuma can publish to ntfy as a notification provider once you have this running.

And if the alert volume is high enough that grouping, silencing, and inhibition matter, keep that logic in Alertmanager where it belongs. ntfy has no dedup and no maintenance windows — hand it messages that are already worth waking up for.

The reference material worth having open is the ntfy documentation for config keys and publishing options, and the ntfy repository for release notes when a setting behaves differently than the docs describe.

If alerts fire into an empty room after hours, that’s exactly what 24/7 Monitoring & Response closes — book a monitoring and response review.