# systemd service

> Run the panel binary as a native service that restarts on boot and on failure.

Source: https://joinnasnet.com/en/guides/nasnet-linux/install/systemd/
Last updated: 2026-08-14

---

## Overview

In systemd mode the panel runs as the plain `nasnet-panel` binary managed by a
unit file, with no Docker involved. The guided installer writes this unit for
you when you pick systemd deployment; this page shows what it produces so you
can review it, reproduce it by hand, or debug a running install.

## Before you start

- A systemd-based Linux distribution (`systemctl` must exist).
- The `nasnet-panel` binary in place and a `.env` file next to it.
- A reachable database, either PostgreSQL on the host or `DB_DRIVER=sqlite`.

## Steps

1. Install the binary at `/usr/local/nasnet-panel/bin/nasnet-panel` and put your
   `.env` at `/usr/local/nasnet-panel/.env`.
2. Write the unit at `/etc/systemd/system/nasnet-panel.service`:

   ```ini
   [Unit]
   Description=nasnet-panel Backend API
   Documentation=https://github.com/nasnet-community/nasnet-panel-linux
   After=network-online.target
   Wants=network-online.target

   [Service]
   Type=simple
   WorkingDirectory=/usr/local/nasnet-panel
   EnvironmentFile=/usr/local/nasnet-panel/.env
   ExecStart=/usr/local/nasnet-panel/bin/nasnet-panel serve
   Restart=always
   RestartSec=5
   LimitNOFILE=65536

   StandardOutput=journal
   StandardError=journal
   SyslogIdentifier=nasnet-panel

   [Install]
   WantedBy=multi-user.target
   ```

   When PostgreSQL runs on the same host, the installer additionally adds the
   database unit to `After=` and to a `Requires=` line, and sets
   `Environment=DB_HOST=localhost`.

3. Reload systemd, then enable and start the service.

   ```bash
   sudo systemctl daemon-reload
   sudo systemctl enable nasnet-panel --now
   ```

4. Confirm it is running and read the logs.

   ```bash
   systemctl is-active nasnet-panel
   journalctl -u nasnet-panel -n 50 -f
   ```

## Reference

| Path | What it is |
| ---- | ---------- |
| `/usr/local/nasnet-panel` | Install directory and working directory |
| `/usr/local/nasnet-panel/bin/nasnet-panel` | The panel binary |
| `/usr/local/nasnet-panel/.env` | Environment file loaded by the unit |
| `/etc/systemd/system/nasnet-panel.service` | The unit file |
| `/usr/local/nasnet-pgsql` | Install directory for the bundled PostgreSQL, when used |
| `nasnet-postgresql.service` | The bundled PostgreSQL unit, when used |

## Troubleshooting

**The service starts and immediately dies.** `Restart=always` will keep retrying
every five seconds, so watch `journalctl -u nasnet-panel -n 50` for the real
error. A short `JWT_SECRET_KEY` (under 32 characters) and an unreachable
database are the two most common causes.

## Related

- [Guided installer](/en/guides/nasnet-linux/install/installer-script/)
- [Release binaries](/en/guides/nasnet-linux/install/binaries/)
- [Offline bundle](/en/guides/nasnet-linux/install/offline-bundle/)
