Skip to content
🧮 Is Lifetime with ZapX Pass worth it? Work it out for your own servers in 30 seconds. Open the Lifetime calculator →

Set Up ntfy on a Linux Server – Push Notifications on Your Phone

Set up ntfy on your Linux server as a One-Click App with HTTPS or manually using Docker Compose. Configure access control, users, and access tokens; connect the Android or iPhone app; and send notifications from scripts, backups, and monitoring tools.

2 December 202614 min read25 Views0 helpful

Introduction

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.

When ntfy Makes Sense on a VPS

Running your own ntfy server is especially worthwhile if:

  • You want scripts, backups, and cron jobs to notify you. A single line of curl at 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.

ntfy.sh or Your Own Server?

The ntfy apps work with both the public server ntfy.sh and your own server. The main difference is access control.

Public server ntfy.shYour own server
SetupNone, ready to useInstall once
AccessAnyone who knows a topic name can read and send messagesOnly with a user account or access token
LimitsFixed ntfy.sh limits, such as 250 messages per daySet by you
DataStored by ntfy.shStored on your server
iPhoneInstant notifications without any extra setupInstant 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 Easy Way: ntfy as a One-Click App

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.

Requirements

  • 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.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search for ntfy in the App catalog and click Install app.
  3. 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.
  4. Under App configuration, you’ll see 23 optional variables, such as NTFY_CACHE_DURATION and NTFY_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.

First Login and Credentials

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.”

Access Control: Who Can Send and Read Messages?

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_ACCESS is set to deny-all. No one can send or read messages without signing in. In testing, anonymous requests returned a 403 error.
  • NTFY_ENABLE_SIGNUP is set to false. Visitors cannot create their own accounts.
  • The admin account in App environment can read and write to all topics.
Warning: Don’t change deny-all lightly

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.

Additional Users and Access Tokens

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:

Code
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.

Updates and backups

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/_data contains auth.db: accounts, permissions, and access tokens. This is the most important file to back up.
  • /var/lib/docker/volumes/<ID>_ntfy-cache/_data contains cache.db and the attachments folder: cached messages and attachments. ntfy deletes both after NTFY_CACHE_DURATION and NTFY_ATTACHMENT_EXPIRY_DURATION expire (24 hours each).

To make a backup, stop the app under App actions, copy auth.db to another system, and start the app again.

Manual Installation

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.

Requirements

  • 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.
HardwareMinimumRecommended
RAMNo fixed requirement; ntfy uses very littleSome extra capacity if many devices are connected at the same time
CPUNo fixed requirement1 to 2 cores if other services are running too
Storage spaceUnder 1 GB for the application and databasesAdditional 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.

Prepare the Firewall

Only SSH and the reverse proxy for HTTPS need to be accessible from outside. With ufw, the commands look like this:

Code
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.

Warning: Docker bypasses ufw

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.

Install with Docker Compose

Create a directory with subfolders for configuration, cache, and the user database:

Code
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:

Code
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-file and cache-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-file and auth-default-access: Enable user management. With deny-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:

Code
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 port 80 inside the container and is only accessible on the server at 127.0.0.1:2586. External access goes through the reverse proxy.
  • healthcheck and init: Docker regularly checks whether ntfy is responding. According to ntfy, init: true is also required for the health check.

Start ntfy from the same directory:

Code
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.

First Access and Admin Account

Create the admin account from the console. The command will prompt you to enter the password twice:

Code
docker compose exec ntfy ntfy user add --role=admin admin

Test the server directly on the server before making it accessible externally:

Code
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.

HTTPS Access Through a Reverse Proxy

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:

Code
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.

Tip: Use Caddy instead of nginx

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.

Back Up Your Data

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:

Code
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.

Update ntfy

Create a backup first. Then enter the new version for image in compose.yaml and pull it:

Code
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.

Send and Receive Notifications

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.

Subscribe with the Mobile App

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.

  1. Open the app and tap the plus icon to subscribe to a topic.
  2. Enter the topic name, for example backups.
  3. Enable “Use another server” and enter your server’s address, for example https://ntfy.example.com.
  4. 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.

iPhone: Instant Notifications via ntfy.sh

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.

Info: Without upstream-base-url, messages arrive late on iPhone

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.

Send a Message from a Script

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:

Code
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) to 5 (max or urgent); the default is 3. At 4 (high) or above, your phone displays a prominent alert with vibration.
  • Tags: Comma-separated, for example warning for ⚠️ or floppy_disk for 💾.
  • Authentication: You can also use -u USER:PASSWORD instead 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:

Code
#!/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.

Receive Messages Programmatically

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):

Code
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.

ntfy Limitations

  • 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, and NTFY_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.

Conclusion

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! 🙂

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the quickest option: ntfy runs over HTTPS on your domain in about a minute, is protected by an admin account and deny-all access by default, and can be updated from the dashboard. Manual installation with Docker Compose is a good choice if you want to manage settings in your own server.yml file, control the version yourself, or run ntfy behind an existing reverse proxy.
Not with the One-Click App: NTFY_AUTH_DEFAULT_ACCESS is set to deny-all and sign-ups are disabled, so the server rejects unauthenticated requests with 403. A manual installation is open to everyone unless you configure it. Set auth-file and auth-default-access: deny-all, then create accounts with ntfy user add.
iOS doesn’t allow apps to maintain a persistent connection in the background. Instant notifications on your own server only work if upstream-base-url is set to https://ntfy.sh (UPSTREAM_BASE_URL in the One-Click App, where it’s set by default). Your server then sends only the message ID to ntfy.sh, and your iPhone retrieves the content from your server. Without this setting, ntfy says messages can take minutes or hours to arrive.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.