How to Install Ntfy on Ubuntu 24.04
Ntfy is a self-hosted push notification service that lets you send messages to phones, browsers, or command-line clients with ease. It supports simple HTTP requests, MQTT, and CLI commands, making it perfect for system alerts, application events, and IoT integrations.
This guide shows how to deploy it using systemd, with proper user permissions, firewall configuration, and basic setup.
Why Use Ntfy?
-
Instant Notifications – Send messages to clients in real time with just a single HTTP POST.
-
Self-Hosted Privacy – Keep your topics and messages under your full control.
-
Simple API – Publish and subscribe using cURL, CLI, or MQTT.
-
Cross-Platform Clients – Works with Android, iOS, desktop, and browser-based apps.
Step 1: Install Required Packages
Ntfy requires basic tools like wget
and curl
to download the binary:
sudo apt update
sudo apt install -y wget curl
Step 2: Create Dedicated User and Directories
For security, run ntfy as a dedicated system user:
sudo useradd -r -s /bin/false -d /nonexistent ntfy
Create required directories:
sudo mkdir -p /etc/ntfy /var/cache/ntfy/attachments
sudo chown -R ntfy:ntfy /etc/ntfy /var/cache/ntfy
sudo chmod -R 755 /var/cache/ntfy /var/cache/ntfy/attachments
Step 3: Download and Install ntfy Binary
Download the latest ntfy release and install it:
wget -q -O /tmp/ntfy.tar.gz https://github.com/binwiederhier/ntfy/releases/latest/download/ntfy_linux_amd64.tar.gz
tar -xzf /tmp/ntfy.tar.gz -C /tmp --strip-components=1
sudo cp /tmp/ntfy /usr/local/bin/ntfy
sudo chmod +x /usr/local/bin/ntfy
Enable binding to low ports (like 80) without root:
sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/ntfy
Step 4: Configure ntfy
Create the server configuration file:
sudo tee /etc/ntfy/server.yml > /dev/null <<EOF
base-url: "http://0.0.0.0:80"
listen-http: ":80"
cache-file: "/var/cache/ntfy/cache.db"
attachment-cache-dir: "/var/cache/ntfy/attachments"
auth-file: "/etc/ntfy/user.db"
behind-proxy: false
enable-login: false
enable-signup: false
cache-duration: "12h"
EOF
sudo chown ntfy:ntfy /etc/ntfy/server.yml
sudo chmod 640 /etc/ntfy/server.yml
Step 5: Create Systemd Service
Set up ntfy to start automatically on boot:
sudo tee /etc/systemd/system/ntfy.service > /dev/null <<EOF
[Unit]
Description=ntfy push notifications service
After=network.target
[Service]
Type=simple
User=ntfy
Group=ntfy
ExecStart=/usr/local/bin/ntfy serve --config /etc/ntfy/server.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl enable --now ntfy
Step 6: Configure Firewall
Allow HTTP traffic for ntfy:
sudo ufw allow 80/tcp
Access Information
-
Service URL:
http://<server-ip>:80
-
Systemd Service:
sudo systemctl status ntfy
-
Firewall Port: 80/tcp
Features of this Deployment
-
Runs as a dedicated system user (
ntfy
) for security -
Uses systemd for automatic startup and restarts
-
Supports caching and attachment storage
-
Allows binding to port 80 without root privilege
Your ntfy push notification service is now fully operational and ready to send notifications to your clients.