ntfy (pronounced “notify”) is a free push notification service that you can host yourself. You send a message to your server with a simple HTTP request, for example using curl from a script, and it appears on your phone, in your browser, or on your desktop as a notification a few seconds later. This way, you know right away when a backup is finished, a disk is running out of space, or a service goes down. ntfy is open source and free of charge.
In this guide, we’ll show you two ways to get started: the easy way with your server’s One-Click Apps and the manual installation using Docker Compose. Then you’ll connect the mobile app, send messages from your own scripts, and secure your server with users and access tokens.
Running your own ntfy server is especially worthwhile if:
- You want scripts, backups, and cron jobs to notify you. A single line of
curlat the end of a script is all it takes; you don’t need a dedicated app or bot. - You want to consolidate alerts from monitoring and automation. Tools such as Uptime Kuma, Grafana, n8n, or Home Assistant can send messages to ntfy, so everything appears in one app.
- You don’t want your messages to go through a third-party provider. Your content, users, and message history stay on your server.
- You want notifications to arrive around the clock. The server runs in a data center and remains accessible even if the power or internet goes out at home.
- You don’t want to share the limits of a public service. You set your own limits, such as messages per day or attachment size.
ntfy is less suitable if you’re looking for a chat app: ntfy sends short notifications to subscribed topics, but it doesn’t support conversations with replies. If you only need to send a test message now and then, the public server ntfy.sh is also an option.
The ntfy apps work with both the public server ntfy.sh and your own server. The main difference is access control.
| Public server ntfy.sh | Your own server | |
|---|---|---|
| Setup | None, ready to use | Install once |
| Access | Anyone who knows a topic name can read and send messages | Only with a user account or access token |
| Limits | Fixed ntfy.sh limits, such as 250 messages per day | Set by you |
| Data | Stored by ntfy.sh | Stored on your server |
| iPhone | Instant notifications without any extra setup | Instant notifications via ntfy.sh, as described below |
For notifications from your own systems, such as backups or server status updates, a self-hosted server with access control is the safer choice.
The quickest way to get your own ntfy server is through your server’s One-Click Apps. ZapX sets up the domain, HTTPS, and an admin account for you, so you don’t need to use the console for installation.
- A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Set Up One-Click Apps for instructions.
- ntfy requires very few resources. A small VPS is enough, even if other apps are already running on it.
- Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
- Search for ntfy in the App catalog and click Install app.
- Leave Use a custom subdomain or zap.cloud enabled and choose an address. The mobile apps and web interface require HTTPS; without a domain, ntfy is only available over HTTP.
- Under App configuration, you’ll see 23 optional variables, such as
NTFY_CACHE_DURATIONandNTFY_VISITOR_MESSAGE_DAILY_LIMIT. You don’t need to change anything. Click Queue installation. The app will be online in about a minute.
The One-Click App automatically sets your server’s address as NTFY_BASE_URL. ntfy needs this, among other things, for links to attachments and for the iPhone app.
The panel generates the admin account’s username and password during installation. You can find them in the app settings (gear icon) under App environment > Automatically generated values: SERVICE_USER_NTFY is the username, and SERVICE_PASSWORD_NTFY is the password.
Open ntfy using the Access link and sign in using the account icon in the top-right corner. Then subscribe to a topic on the left using “Subscribe to topic,” for example backups, to see all the messages sent to that topic. You can send a test message directly in the browser using “Publish notification.”
Without access control, anyone who knows the address can read and send messages to any topic in ntfy. The One-Click App is secured by default:
NTFY_AUTH_DEFAULT_ACCESSis set todeny-all. No one can send or read messages without signing in. In testing, anonymous requests returned a403error.NTFY_ENABLE_SIGNUPis set tofalse. Visitors cannot create their own accounts.- The admin account in App environment can read and write to all topics.
If you set NTFY_AUTH_DEFAULT_ACCESS to read-write, your server will be open to everyone. Anyone could post to your topics and read your messages. Instead, grant access to individual topics as needed, as shown in the next section.
Create separate accounts with limited permissions for scripts and family members. You can do this from your VPS console. To find the container name, run docker ps | grep ntfy; for example, ntfy-abc123:
docker exec -it ntfy-abc123 ntfy user add backup
docker exec -it ntfy-abc123 ntfy access backup backups wo
docker exec -it ntfy-abc123 ntfy token add --label=backup-script backup
The first command creates the backup account and prompts you for a password. The second allows this account to send messages only (wo, write-only) to the backups topic. The third creates an access token that starts with tk_. In testing, the account could send messages to backups using this token; attempts to send to other topics or read messages were rejected with 403. Other permissions are ro (read-only) and rw (read and write). Run ntfy user list to see all accounts and their permissions.
Accounts created this way remain in place after restarts and updates. You can also create access tokens in the web interface under “Account” when you’re signed in.
Update ntfy in the app settings (gear icon) under App update. Click Check for updates, then install a new version using Apply update. If the page says the app is up to date, no newer version is available in the app catalog yet.
The data is stored in two Docker volumes on your server. The ID is the part of the container name after ntfy-:
/var/lib/docker/volumes/<ID>_ntfy-db/_datacontainsauth.db: accounts, permissions, and access tokens. This is the most important file to back up./var/lib/docker/volumes/<ID>_ntfy-cache/_datacontainscache.dband theattachmentsfolder: cached messages and attachments. ntfy deletes both afterNTFY_CACHE_DURATIONandNTFY_ATTACHMENT_EXPIRY_DURATIONexpire (24 hours each).
To make a backup, stop the app under App actions, copy auth.db to another system, and start the app again.
The rest of this guide covers manual installation from the console using Docker Compose. For example, you might want to integrate ntfy into an existing server environment or manage all settings in your own configuration file. The instructions are based on the official ntfy installation guide and the configuration reference for version 2.38.
- A Linux server running Debian or Ubuntu that you can access over SSH.
- Docker with the Compose plugin. See our guide to Set Up Docker for instructions on installing Docker.
- A domain or subdomain with an A record pointing to your server’s IP address (e.g.,
ntfy.example.com). The mobile apps require HTTPS.
| Hardware | Minimum | Recommended |
|---|---|---|
| RAM | No fixed requirement; ntfy uses very little | Some extra capacity if many devices are connected at the same time |
| CPU | No fixed requirement | 1 to 2 cores if other services are running too |
| Storage space | Under 1 GB for the application and databases | Additional space for attachments if you send files |
ntfy doesn’t specify fixed minimum requirements. Each connected device keeps a persistent connection open, but this uses very few resources.
Only SSH and the reverse proxy for HTTPS need to be accessible from outside. With ufw, the commands look like this:
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Don’t open the ntfy port. For more information, see Managing the Firewall on Linux.
When Docker publishes a port on all network interfaces, it adds its rules outside of ufw. The port would then be accessible from outside despite the firewall. Bind ntfy to 127.0.0.1 instead, as shown in the next step.
Create a directory with subfolders for configuration, cache, and the user database:
mkdir -p /opt/ntfy/etc /opt/ntfy/cache /opt/ntfy/lib
cd /opt/ntfy
nano etc/server.yml
The Docker image doesn’t include a server.yml file. Add the following content and replace the address with your domain:
base-url: "https://ntfy.example.com"
listen-http: ":80"
behind-proxy: true
cache-file: "/var/cache/ntfy/cache.db"
cache-duration: "12h"
attachment-cache-dir: "/var/cache/ntfy/attachments"
auth-file: "/var/lib/ntfy/user.db"
auth-default-access: "deny-all"
enable-login: true
upstream-base-url: "https://ntfy.sh"
The most important lines:
base-url: Your server’s public address. Attachments and the iPhone app won’t work properly without it.behind-proxy: Required when running behind a reverse proxy. Otherwise, ntfy counts all visitors as one, and the limits apply to everyone collectively.cache-fileandcache-duration: Messages are stored for 12 hours. Devices that were briefly offline can retrieve them during that time.attachment-cache-dir: ntfy rejects attachments if this directory is missing.auth-fileandauth-default-access: Enable user management. Withdeny-all, no one can send or read messages without signing in.upstream-base-url: Required for instant notifications on iPhone. See “iPhone: Instant Notifications via ntfy.sh.”
Then create the compose.yaml file:
services:
ntfy:
image: binwiederhier/ntfy:v2.38.0
container_name: ntfy
command:
- serve
environment:
- TZ=Europe/Berlin
volumes:
- ./etc:/etc/ntfy
- ./cache:/var/cache/ntfy
- ./lib:/var/lib/ntfy
ports:
- 127.0.0.1:2586:80
healthcheck:
test: ["CMD-SHELL", "wget -q --tries=1 http://localhost:80/v1/health -O - | grep -Eo '\"healthy\"\\s*:\\s*true' || exit 1"]
interval: 60s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
init: true
image: The official image with a fixed version. This lets you decide when to update.ports: ntfy listens on port80inside the container and is only accessible on the server at127.0.0.1:2586. External access goes through the reverse proxy.healthcheckandinit: Docker regularly checks whether ntfy is responding. According to ntfy,init: trueis also required for the health check.
Start ntfy from the same directory:
docker compose up -d
Check whether the container is running with docker compose ps, and view the logs with docker compose logs -f. After startup, the log will show Listening on :80[http], ntfy 2.38.0.
Create the admin account from the console. The command will prompt you to enter the password twice:
docker compose exec ntfy ntfy user add --role=admin admin
Test the server directly on the server before making it accessible externally:
curl -u admin:PASSWORD -d "Hello from the server" http://127.0.0.1:2586/test
If you get a response containing "event":"message", ntfy is running. Without -u, ntfy rejects the request with 403, as it should.
For the basics, see Set Up a Reverse Proxy with nginx and Create an SSL Certificate (Let's Encrypt). Two things are important for ntfy: apps and browsers keep connections open for a long time, and ntfy uses WebSockets. The following nginx server block is based on the template in the ntfy documentation:
server {
listen 80;
server_name ntfy.example.com;
location / {
proxy_pass http://127.0.0.1:2586;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
}
}
proxy_buffering off forwards messages to devices immediately, while Upgrade and Connection enable WebSockets. proxy_read_timeout 3m keeps connections open because ntfy sends a keep-alive signal every 45 seconds by default. X-Forwarded-For provides the visitors’ real IP addresses, as required by behind-proxy: true.
Then get the certificate using certbot --nginx -d ntfy.example.com. Certbot adds HTTPS and the HTTP redirect to the block.
Caddy takes less configuration because it obtains the certificate itself and forwards WebSockets automatically. Just add ntfy.example.com { reverse_proxy 127.0.0.1:2586 } to the Caddyfile.
The files you need to back up are the configuration file /opt/ntfy/etc/server.yml and the user database /opt/ntfy/lib/user.db, which contains accounts, permissions, and access tokens. ntfy automatically deletes cached messages after cache-duration expires. To ensure the database is in a consistent state, briefly stop ntfy:
cd /opt/ntfy
docker compose stop
tar czf /root/ntfy-backup-$(date +%F).tar.gz etc lib
docker compose start
Then copy the archive to another system, for example with rsync or scp.
Create a backup first. Then enter the new version for image in compose.yaml and pull it:
cd /opt/ntfy
docker compose pull
docker compose up -d
Read the ntfy release notes first. You can remove old images afterward with docker image prune.
Whether you’re using the One-Click App or a manual installation, the process is the same from here on. In the examples, ntfy.example.com represents your server’s address.
ntfy messages are always sent to a topic, for example backups or monitoring. A topic is created when the first message is sent. Topic names can include letters, numbers, -, and _. You can use a separate topic for each type of notification and mute them individually in the app.
The official app is available for Android on Google Play and F-Droid, and for iPhone on the App Store.
- Open the app and tap the plus icon to subscribe to a topic.
- Enter the topic name, for example
backups. - Enable “Use another server” and enter your server’s address, for example
https://ntfy.example.com. - Since your server is protected, the app will ask for a username and password. Use an account that has permission to read the topic.
On Android, the app maintains a persistent connection for your own servers. According to ntfy, it doesn’t use Firebase for self-hosted servers. You’ll see a persistent notification from the app, which you can hide in Android settings.
iOS doesn’t allow apps to maintain a persistent connection in the background. Instant notifications can only be delivered through Apple’s push service, which is only connected to the public server ntfy.sh. For this reason, according to the ntfy documentation, your server forwards a short notification retrieval request to ntfy.sh for each message. The setting for this is upstream-base-url (or UPSTREAM_BASE_URL in the One-Click App, which is already set to https://ntfy.sh).
This request contains only the message ID and a checksum of the topic address, not the message text. During testing, ntfy.sh only received the placeholder “New message.” The iPhone wakes up and retrieves the actual message directly from your server.
If you leave this setting blank, no data goes through ntfy.sh. However, according to ntfy, messages may then take 20 to 30 minutes to reach your iPhone if you’re using it, or even several hours otherwise. This setting isn’t needed for Android.
If you send a lot of messages, ntfy.sh may slow down your server. To prevent this, use upstream-access-token (or UPSTREAM_ACCESS_TOKEN in the One-Click App) with a token from an ntfy.sh account.
A message is a simple HTTP request. Use headers to set a title, priority, and tags. Tags that match an emoji name appear as an emoji before the title:
curl \
-H "Authorization: Bearer tk_ACCESS_TOKEN" \
-H "Title: Backup finished" \
-H "Priority: high" \
-H "Tags: white_check_mark,floppy_disk" \
-d "Backup of /var/www completed" \
https://ntfy.example.com/backups
Priority:1(min) to5(max or urgent); the default is3. At4(high) or above, your phone displays a prominent alert with vibration.Tags: Comma-separated, for examplewarningfor ⚠️ orfloppy_diskfor 💾.- Authentication: You can also use
-u USER:PASSWORDinstead of a token. A token can be revoked at any time without changing passwords, making it the better choice for scripts.
Here’s an example of a backup script that sends an urgent notification only if something goes wrong:
#!/bin/bash
if ! tar czf /root/backup-$(date +%F).tar.gz /var/www; then
curl -s -H "Authorization: Bearer tk_ACCESS_TOKEN" \
-H "Title: Backup failed" -H "Priority: urgent" -H "Tags: rotating_light" \
-d "Backup on $(hostname) failed" https://ntfy.example.com/backups
fi
For more options, such as attachments (-T datei.txt), a link to open when tapped (Click), or delayed messages (Delay), see the ntfy documentation on sending messages.
In addition to the apps, you can retrieve messages yourself, for example for custom reporting. ntfy provides a continuous stream of data in JSON format or as Server-Sent Events (SSE):
curl -s -H "Authorization: Bearer tk_ACCESS_TOKEN" https://ntfy.example.com/backups/json
curl -s -H "Authorization: Bearer tk_ACCESS_TOKEN" https://ntfy.example.com/backups/sse
The connection stays open, and each new message appears on a separate line. Instead, use /backups/json?poll=1 to retrieve all cached messages once and close the connection. The account or token must have read access to the topic.
- Messages per day: By default, the One-Click App allows 100 messages per day per visitor using
NTFY_VISITOR_MESSAGE_DAILY_LIMIT. If your scripts send more, increase the value in App environment. - Length: A message can be up to 4,096 bytes long. ntfy treats longer texts as attachments.
- Attachments: The One-Click App allows files up to 10 MB each and 1 GB in total; ntfy deletes them after 24 hours. Change these limits using
NTFY_ATTACHMENT_FILE_SIZE_LIMIT,NTFY_ATTACHMENT_TOTAL_SIZE_LIMIT, andNTFY_ATTACHMENT_EXPIRY_DURATION. - No permanent history: The server stores messages only for the duration set by
cache-duration. Any messages a device doesn’t retrieve during that time are lost. The apps keep received messages locally. - Access tokens can’t have separate permissions: According to ntfy, a token has the same permissions as its account. For scripts, create separate accounts with limited permissions instead of using the admin account.
- Formatting: The Android app and web interface display Markdown in messages (
Markdown: yes), but the iPhone app does not.
With ntfy, you now get notifications from backups, monitoring, and automation on your phone right away, protected from unauthorized access and without a third-party provider. To go with it, the guide Set Up Uptime Kuma on a Linux Server shows you how to monitor your websites and services and get alerted via ntfy when something goes down.
If you have any other questions or need help, our support team is available every day! 🙂
