To monitor multiple servers with Beszel in Docker Compose, deploy one central Beszel Hub container (henrygd/beszel:latest) on your management host and one henrygd/beszel-agent:latest container on every monitored host. Connect the hub’s own host over a shared Unix socket, and connect remote hosts through either agent-initiated WebSockets with a universal token or hub-initiated SSH on its default TCP port, 45876.
This walkthrough covers the full hub stack, multi-host agent deployment, extra disk mounts, reverse proxy WebSocket rules, and connection troubleshooting. Browse the Homelab Monitor Lab posts page.
Choose a Hub-to-Agent Connection Mode
| Connection Mode | Who Initiates | Key Agent Variables | Inbound Port on Agent | Best Fit |
|---|---|---|---|---|
| Local Unix socket | Hub connects through a shared socket | LISTEN: /beszel_socket/beszel.sock, KEY, TOKEN, HUB_URL | None | Monitoring the host that runs Beszel Hub |
| WebSocket | Agent connects out to /api/beszel/agent-connect | HUB_URL, TOKEN, KEY (optional DISABLE_SSH: true) | None for WebSocket | Multiple remote hosts, untrusted networks over HTTPS |
| SSH | Hub connects out to agent | LISTEN: 45876, KEY | TCP 45876 (or custom) | Trusted network where the hub can reach agents that cannot reach the hub |
According to the Beszel Security documentation, the hub generates an ED25519 key pair on first start. With the single-key KEY settings shown below, the agent’s built-in SSH server accepts only the hub’s public key. It provides no pseudo-terminal (pty) and accepts no command input. Even with the private key, a client cannot execute commands through the agent’s built-in SSH server.
In SSH mode, the hub does not verify the agent’s SSH host key. Someone who can intercept SSH traffic could impersonate an agent and submit false metrics. The Beszel security guide recommends WebSocket mode with an HTTPS hub URL over untrusted networks.
Deploy the Beszel Hub and Local Agent
The Beszel Hub Installation Guide provides a Compose file for running the hub and a local agent together. The hub connects to the local agent through a Unix socket in the shared ./beszel_socket directory.
Create a project folder and docker-compose.yml on the hub host:
mkdir beszel
cd beszel
services:
beszel:
image: henrygd/beszel:latest
container_name: beszel
restart: unless-stopped
environment:
APP_URL: http://localhost:8090
ports:
- 8090:8090
volumes:
- ./beszel_data:/beszel_data
- ./beszel_socket:/beszel_socket
beszel-agent:
image: henrygd/beszel-agent:latest
container_name: beszel-agent
restart: unless-stopped
network_mode: host
volumes:
- ./beszel_agent_data:/var/lib/beszel-agent
- ./beszel_socket:/beszel_socket
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
LISTEN: /beszel_socket/beszel.sock
HUB_URL: http://localhost:8090
TOKEN: "<token>"
KEY: "<key>"
Set APP_URL to the URL you use to reach the hub (for example, https://beszel.example.com). As noted in the Beszel Environment Variables Reference, APP_URL controls links in emails and notifications and is required if you serve the hub under a subpath.
Complete the initial bootstrap in this order, following the Beszel Getting Started Guide:
- Start the stack with
docker compose up -d. - Open
http://localhost:8090(or your hub host IP on port8090) in a browser and create the admin account. - Click Add System in the hub dashboard.
- Enter
/beszel_socket/beszel.sockin the Host / IP field for the local agent. - Copy the public key and token from the dialog.
- Paste those values into
KEYandTOKENindocker-compose.yml, then rundocker compose up -dto restart the agent. - Click Add System in the dialog after the agent starts.
The ./beszel_data:/beszel_data bind mount provides persistent storage for the hub. The agent uses the Docker socket mount for container statistics. With network_mode: host, it can access the host’s network interface statistics.
Deploy Remote Agents Across Multiple Hosts with a Universal Token
With a universal token, remote agents can register over WebSockets without being set up in the hub ahead of time. Beszel Agent Installation Guide
First, get a universal token from /settings/tokens in the Beszel Hub web UI. Keep both that token and the hub’s ED25519 public key handy.
Next, deploy the following docker-compose.yml on each remote Docker host:
services:
beszel-agent:
image: henrygd/beszel-agent:latest
container_name: beszel-agent
restart: unless-stopped
network_mode: host
volumes:
- ./beszel_agent_data:/var/lib/beszel-agent
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
HUB_URL: "https://beszel.example.com"
TOKEN: "<universal-token>"
KEY: "<hub-public-key>"
DISABLE_SSH: "true"
Start each remote agent with docker compose up -d.
- Persist the fingerprint. The agent’s data directory stores its system fingerprint. The Compose file mounts
./beszel_agent_dataat/var/lib/beszel-agent. - Keep
SYSTEM_NAMEoptional: When unset, the agent registers using the host’s own system hostname. SetSYSTEM_NAMEonly when you want a custom label in the hub UI. - Optionally disable SSH: Setting
DISABLE_SSH: "true"on the agent turns off its built-in SSH server so the node operates in WebSocket-only mode. SettingDISABLE_SSH: "true"on the hub disables hub-initiated SSH and requires agents to connect via WebSocket. The hub setting defaults tofalse. - Read the key and token from files. The agent supports
KEY_FILEandTOKEN_FILEas alternatives to inline values.
Configure Remote Agents in Hub-Initiated SSH Mode
Use SSH mode when the hub can reach remote agents over a trusted network and the agents cannot reach the hub.
In the Beszel Hub UI, click Add System. Set the remote host’s address and SSH port on the system you’re adding, using 45876 by default or the port you set in the agent’s LISTEN variable. Copy the generated Compose snippet or public key. Deploy this Compose file on the remote host.
services:
beszel-agent:
image: henrygd/beszel-agent:latest
container_name: beszel-agent
restart: unless-stopped
network_mode: host
volumes:
- ./beszel_agent_data:/var/lib/beszel-agent
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
LISTEN: 45876
KEY: "<hub-public-key>"
Allow inbound TCP traffic on port 45876 (or whichever port you assign to LISTEN) in the remote host’s firewall or security group. Start the container with docker compose up -d, then click Add System in the dialog.
Key Environment Variables for Multi-Host Deployments
Hub environment variables can optionally use the BESZEL_HUB_ prefix. In the Compose examples, agent variables are set on the beszel-agent service.
| Component | Variable | Default | Purpose |
|---|---|---|---|
| Hub | APP_URL | Unset | Hub URL for notification links and subpath deployments |
| Hub | DISABLE_SSH | false | Turns off outgoing SSH connections so agents must connect by WebSocket |
| Agent | LISTEN | 45876 | TCP port, literal IP with port, or full Unix socket path for incoming hub connections |
| Agent | HUB_URL | Unset | Hub URL for outbound agent WebSocket connections |
| Agent | KEY / KEY_FILE | Unset | Hub ED25519 public key(s) inline (newline-separated) or from a file |
| Agent | TOKEN / TOKEN_FILE | Unset | System or universal authentication token inline or from a file |
| Agent | DISABLE_SSH | false | Disables the agent’s internal SSH server for WebSocket-only operation |
| Agent | SYSTEM_NAME | Unset | Custom system name for universal token registration, falling back to the hostname |
Monitor Additional Disks on Docker Hosts
When FILESYSTEM is unset, the agent tries to use the partition mounted at / for root disk stats. This autodetection may fail in a container. For a Docker agent, mount a folder from each target filesystem in the container’s /extra-filesystems/ directory. Beszel Additional Disks Guide
Use lsblk to find the kernel device name (KNAME) and mount point.
lsblk -o NAME,KNAME,SIZE,TYPE,MOUNTPOINT
Add mounts for folders on the target filesystems to beszel-agent in docker-compose.yml.
volumes:
- ./beszel_agent_data:/var/lib/beszel-agent
- /var/run/docker.sock:/var/run/docker.sock:ro
- /mnt/disk1/.beszel:/extra-filesystems/sdb1:ro
- /mnt/media/.beszel:/extra-filesystems/sdc1__Media:ro
Using the kernel name (KNAME) in place of the device-mapper name (NAME) can fix disk I/O reporting for encrypted devices or logical volumes. Appending two underscores followed by a label (such as sdc1__Media) sets a custom display name in the hub dashboard. Disk I/O statistics are unavailable for network-mounted drives.
Configure a Reverse Proxy for WebSocket Agents
When remote hosts connect through a reverse proxy, make sure the proxy supports WebSocket connections to /api/beszel/agent-connect. For a root-path proxy, the Beszel documentation recommends setting APP_URL on the hub container to the external URL. For a subpath deployment, APP_URL is required and must include the subpath. The Nginx and Caddy blocks below serve Beszel at the root path.
Nginx Reverse Proxy
The Beszel documentation’s HTTP example for Nginx listens on port 80 and sets the Upgrade and Connection headers and a read timeout. The remote agent example uses an HTTPS HUB_URL, which requires TLS termination separately from this HTTP block.
server {
listen 80;
server_name beszel.example.com;
client_max_body_size 10M;
location / {
proxy_read_timeout 360s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8090;
}
}
Caddy Reverse Proxy
The Caddy example sets a 10 MB body limit and a 360-second read timeout.
beszel.example.com {
request_body {
max_size 10MB
}
reverse_proxy 127.0.0.1:8090 {
transport http {
read_timeout 360s
}
}
}
The Beszel Reverse Proxy Guide shows a Traefik configuration using Docker labels. For Server-Sent Events (SSE) in the web UI to work reliably, disable gzip or other proxy compression on responses with content type text/event-stream.
Troubleshoot Multi-Host Connection and Metrics Issues
If an agent stays offline or shows incomplete charts, check these settings from the Beszel Common Issues Guide.
- Inspect the logs. Open
/_/#/logson the Beszel Hub for information about the connection error. - Test TCP reachability in SSH mode. Run
telnet <agent-ip> <port>(default port45876) from another device on the network to test connectivity. - Check
iptablesforwarding on the hub host: If the hub host enforcesiptables -P FORWARD DROP, SSH connections to remote agents can fail silently. Switch those agents to WebSocket mode or permit forwarded packets on the hub host. - Verify WebSocket proxying. Confirm the endpoint
/api/beszel/agent-connectis accessible and the reverse proxy supports WebSocket connections. - Tunnel instead of opening ports: If a firewall blocks the connection, WireGuard, Tailscale, Cloudflare Tunnel, or Pangolin are alternatives to opening the agent port.
- Empty or missing container charts. If you use the Compose configuration shown above, confirm the agent has the
/var/run/docker.sock:/var/run/docker.sock:robind mount. Rundocker statson the agent host and check whether it shows zero memory usage. If it does, cgroup memory accounting may need to be enabled. - Unreliable container discovery. A bug in Docker 24 and possibly earlier versions can keep containers from populating reliably. The agent has a partial workaround, and the guide recommends upgrading Docker on the agent host if possible.
Evidence and Limits Note
The official Beszel 0.21.2 documentation was checked on 2026-11-26. The hub and agent Compose examples use the latest image tag. This guide is not based on hands-on testing. See the About page for the site’s editorial approach.