Introduction
In our journey of self-hosting various services, one common need that often arises is the ability to receive notifications.
Initially, I started with sending out these notifications to a Discord private server, but I wanted to move out of Discord and into a self-hosted solution. That’s when I discovered Ntfy ↗️.
Whether it’s alerts from my monitoring system, updates from my download queue, or notifications about system events, having a reliable way to get these messages is crucial. This is where Ntfy comes in – a simple, lightweight, and powerful notification service that you can self-host.
What is Ntfy?
Ntfy ↗️ (pronounced “notify”) is an open-source pub-sub notification service that allows you to send notifications to your phone or desktop using simple HTTP PUT/POST requests. It’s designed to be simple to use yet powerful enough to handle complex notification scenarios.
Key features include:
- Send notifications via simple HTTP requests.
- Mobile apps for Android and iOS.
- Web app for desktop notifications.
- Attachments support (files, images, etc.)
- Priority levels and notification categories.
- First party command line interface (CLI).
- Access control and authentication.
- Simple API that works with curl, wget, or any HTTP client.
Setup Ntfy
The easiest way to set up Ntfy is using Docker. However if you want to run it natively, you can download the binary from the official website ↗️.
Since I’m using Docker, I’ll share on how to set it up using Docker. Create a new directory for Ntfy and create a docker-compose.yml
file with the following content:
If you want, you can configure Ntfy to use a custom domain and enable authentication by adding a server.yml
file in the config
directory:
This is more for security and privacy reasons, if you are running Ntfy on a public server its better to disable signup and enable authentication so that only you can send notifications to your server and not random people.
Read more about the configuration options in the official documentation ↗️.
With that done, create the necessary directories:
And start the container:
Setting Up Authentication
For security, let’s create a user account:
You’ll be prompted to enter a password. Remember these credentials as you’ll need them to access the web UI and send notifications.
Again, you can skip this step if you are running Ntfy in your private homelab and don’t want to enable authentication. (No harm in doing it though)
Using Ntfy
Sending Notifications
The simplest way to send a notification is using curl:
You can also send more complex notifications with priorities, titles, and tags:
Receiving Notifications
- Install the Ntfy app on your phone (Android ↗️ / iOS ↗️)
- Add your Ntfy server (https://ntfy.yourdomain.com ↗️)
- Enter your credentials
- Subscribe to topics you want to receive notifications from
You can also use the web interface at https://ntfy.yourdomain.com ↗️ to manage subscriptions and view notifications.
iOS Users
If you are using iOS app for receiving notifications, keep in mind that there are some known issues ↗️ and you might have trouble receiving notifications.
You can instead maybe use the web interface and install the app as Progressive Web App (PWA) on your phone. Thanks to the suggestion from @SpecificProfession49 ↗️ on Reddit.
How I am using Ntfy
Here are some practical examples of how I am using Ntfy in my homelab:
System Monitoring
This is a simple script that checks the disk space of the root partition and the available memory (RAM) and if they are running low, it sends a notification via Ntfy.
Package Updates
Another simple script to check for updates and send a notification if there are any updates available.
Backup Completion Notification
Majorly every service that I have, which have some dependency on a database or datastore/config in general, I usually have a backup script for it which automatically runs at a specific interval.
Once the backup is finished, I send out a notification to my phone to let me know that the backup has been completed successfully. This one is usually of a lower priority so that it doesn’t clutter my notifications.
And for the failed backups, I send a notification with a higher priority so that I can immediately look into it.
Friendly Advice
One thing to remember when setting up alerts (and this is a general advice and not specific to Ntfy) is that you should not spam yourself with notifications. So if you are setting up alerts for a service, try to set it up in a way that it doesn’t send out a notification every time the service is checked (or even if it does, make sure it’s a low priority notification so you don’t get spammed).
More often than not, you don’t need to be notified every time the service is checked, you just need to be notified when there is an issue.
Conclusion
Ntfy is an invaluable tool in any self-hosted setup, providing a reliable and simple way to implement notifications across your services.
I’ve been using Ntfy for several months now, and it has become an essential part of my homelab monitoring setup. The ability to receive instant notifications about important events has made managing my self-hosted services much more efficient.
Have you implemented Ntfy in your homelab? Do you use some other service for push notifications? Share your experiences in the comments below, or reach out to me on Twitter ↗️ / Reddit ↗️.
Happy notifying!