Areas we serve

Self-Hosted ntfy: Push from a Script Without a Public Topic

The backup script failed at 2 a.m. The only person who would have noticed was asleep, and the log file is not a notification. You can wire that script to someone else’s push service. Or you can POST a sentence to a server you run, and have your phone show it.

ntfy (binwiederhier/ntfy, pronounced “notify”) is that server. Apache-2.0, about 36,000 GitHub stars, docs at ntfy.sh/docs. It is HTTP pub-sub. A topic is a name. Publishing is a PUT or a POST. Subscribing is the phone app, the desktop app, the web page, or ntfy subscribe. The public instance at ntfy.sh needs no account, which is why a one-line curl became the demo:

curl -d "Backup failed on db-1" ntfy.sh/workshopco-backups

That line is also the reason to self-host. The topic name is the password if the server lets anyone publish and anyone subscribe. workshopco-backups on a public server is a guessable mailbox. Your disk alerts, your door sensor, and whatever a script prints do not belong on a host you do not operate.

What it is, and what we already covered

Gotify is the close cousin: a small server and a phone app for your own alerts. ntfy is the same job with a plainer protocol, first-party Android and iOS apps, and a public server people use until they shouldn’t. Notifo and Novu are for notifying your product’s users, with preferences and templates. ntfy is for you, your scripts, and maybe a couple of colleagues. If you need a digest and an embedded inbox, you are in the wrong post.

Publish from cron, Uptime Kuma, a healthchecks job, or a three-line Python script. Headers set a title, a priority, a tag, a click URL, or a delay. Attach a file if the message is a screenshot. The Android app is on F-Droid as well as Play. iOS is on the App Store. The web app is enough when you do not want another install.

Run your own, then lock the topics

The server is one Go binary, or the binwiederhier/ntfy image. A common start publishes port 80 and keeps the cache on a volume so messages survive a restart. Put Caddy or nginx in front with TLS. Phones will not stay subscribed to a cleartext IP for long, and you do not want alert text on the open internet without it.

Then turn on users. ntfy can keep an auth database and a default of deny. Give the backup script a token that can publish to backups and nothing else. Give your phone a user that can subscribe. A random topic on an open server is better than a dictionary word, and worse than real access control. Anyone who can subscribe can read the history the server still has cached.

Android can use ntfy as a UnifiedPush distributor, so other apps on the phone wake up without Firebase. That is a real reason to run your own server if you are trying to keep Google out of the path. iOS still depends on Apple to wake the app. Self-hosting moves the message store to you. It does not repeal Apple’s push rules.

Good fit / skip it

Good fit: homelab and small-office alerts, scripts that should buzz a phone, people who want the protocol to stay a curl command.

Skip it: customer notification workflows, anything that must stay quiet if the topic name leaks, and a public ntfy.sh topic named after your company. That last one is a postcard.

Bottom line

ntfy is a push service you can explain in one HTTP request. Self-host it so the request lands on your disk, put TLS in front, and stop treating the topic name as a secret. The phone app is the easy part. The access list is what keeps last night’s backup failure from becoming someone else’s reading material.

Talk with Swift Host if you want that small Go process on a Canadian VPS, with a name and a certificate, instead of a topic on the public demo server.

Tags:
  • ntfy
  • Push
  • Notifications
  • Docker
  • Self-Hosted

Need Help With Your Hosting?

Tell us about your application — we respond within 1 hour with honest recommendations.