Part 9 — How I Run My Entire Digital Life on a Raspberry Pi: Real-Time Notifications with Gotify

Part 9 — How I Run My Entire Digital Life on a Raspberry Pi: Real-Time Notifications with Gotify

Table of Contents

In this episode, we’re diving into the world of real-time notifications by setting up Gotify — a powerful, open-source, and self-hosted push notification system that puts you in full control of your alerts. Whether you want instant updates from your smart home devices, server status alerts, or custom messages delivered right to your phone or desktop, Gotify makes it simple, secure, and customizable. Join us as we walk through the setup process and unlock a smarter way to stay connected and informed wherever you are!

Image generated by ChatGPT Image generated by ChatGPT

Gotify

Gotify is an open-source, self-hosted push notification server designed to send and receive custom notifications in real time. It provides a simple REST API for sending messages, a web interface for managing and viewing notifications, and client apps — such as an Android app — that deliver push alerts directly to your devices. Gotify is ideal for developers and system administrators who want to create personalized notification systems, enabling alerts from monitoring tools, scripts, or applications to be pushed securely and instantly to phones, desktops, or browsers without relying on third-party services.

The stack

Let’s navigate to our Portainer as usual, and create a new stack as gotify.

services:
  gotify:
    container_name: gotify
    hostname: gotify
    image: gotify/server-arm64
    restart: always
    volumes:
      - "/mnt/storage/docker/gotify:/app/data"
    dns: 172.30.1.3
  environment:
      GOTIFY_DEFAULTUSER_NAME: "admin"   
      GOTIFY_DEFAULTUSER_PASS: "admin"  
    networks:
      pi_docker_network:
        ipv4_address: 172.30.1.15

networks:
  pi_docker_network:
    external: true

The main change in this stack compared to previous setups is the restart policy. I noticed that whenever the stack is relaunched after a reboot, Gotify often throws an error — likely because the Android app tries to connect immediately. However, if I restart the stack through Portainer, everything works as expected. With this new policy, I want Gotify to automatically restart no matter what (i.e., on failure too), hence usingrestart: always, it will also automatically restart on reboot with the additional setting.

The environment variables are only needed for the first time to create your user using the dashboard, after that, you can remove it.

Remote access

As we didn’t expose any ports, let’s straightaway configure our cloudflare tunnel and add a public hostname to access this container remotely. Go to your tunnel’s dashboard and create a new hostname.

Create a new public hostname with proper redirect to our gotify container Create a new public hostname with proper redirect to our gotify container

Save and try it; navigate your browser to your freshly configured domain.

After logging in, you find yourself at this dashboard.

Gotify main dashboard after login Gotify main dashboard after login

The goal of this blog post, much like the previous one, isn’t to provide an in-depth exploration of the service itself, but rather to focus on the deployment process. Still, let’s take a quick look at how handy Gotify can be in practice. In a future episode about Grafana, we’ll go a bit further and demonstrate how to set up an alert and send notifications directly to Gotify.

Click on Users and create a new user. After that, we will define an application. This is basically a notification sub-category; meaning you can send notification to channels corresponding to an application. Let’s say we create an application as “my python codes”.

Create a an application Create a an application

After creating it, you can see it becomes part of the side bar on the left, as well as give you the possibility to change the icon for it; i snatched the opportunity. You can see that the API token is also shown.

Once an application is created, we have this view Once an application is created, we have this view

Reveal the API token for this specific app, and let’s send some notification.

# curl "https://[YOUR_GOTIFY_DOMAIN]/message?token=[YOUR_APP_TOKEN]" \
  -F "title=Machine learning" \
  -F "message=Training the new LLM is finally ready" \
  -F "priority=5"

Once you run this command, the notification appears instantly on your dashboard — how awesome is that?

Notification well received Notification well received

Admittedly, my previous example was a bit basic since Python comes with its own requests library. This means you can send notifications to your Gotify server directly using native Python code, like this:

import requests

# Replace with your Gotify server URL and app token
gotify_url = "https://[YOUR_GOTIFY_DOMAIN]/message?token=[YOUR_APP_TOKEN]"

payload = {
    "title": "Machine learning",
    "message": "Training the new LLM is finally ready",
    "priority": 5
}

response = requests.post(gotify_url, json=payload)

if response.status_code == 200:
    print("Notification sent successfully!")
else:
    print(f"Failed to send notification: {response.status_code} - {response.text}")

As I mentioned earlier, you can install the companion app on your Android or iPhone to receive notifications directly on your mobile device. Could it get any easier? Plus, thanks to the way we deployed it, there’s no need to worry about your messages being sent in plain text — everything is securely encrypted over HTTPS. You’re welcome! 😄

In this blog post, we took a big step toward making your digital life even smarter by setting up Gotify — a sleek, self-hosted notification system that delivers instant alerts right to your devices. We walked through deploying Gotify in a container, creating your admin user effortlessly, and sending your very first notification using both curl and Python. With this powerful setup, you’re now ready to stay connected and informed like never before—no more missing important updates, and all under your full control. How cool is that?