Illustrated title card for the guide: Beszel Hub and Agent Docker Compose Setup for Multiple Hosts
server-monitoring

Beszel Hub and Agent Docker Compose Setup for Multiple Hosts

Deploy Beszel Hub and Docker Compose agents across multiple hosts using Unix sockets, WebSockets, SSH keys, and universal tokens for auto-registration.

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 ModeWho InitiatesKey Agent VariablesInbound Port on AgentBest Fit
Local Unix socketHub connects through a shared socketLISTEN: /beszel_socket/beszel.sock, KEY, TOKEN, HUB_URLNoneMonitoring the host that runs Beszel Hub
WebSocketAgent connects out to /api/beszel/agent-connectHUB_URL, TOKEN, KEY (optional DISABLE_SSH: true)None for WebSocketMultiple remote hosts, untrusted networks over HTTPS
SSHHub connects out to agentLISTEN: 45876, KEYTCP 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:

  1. Start the stack with docker compose up -d.
  2. Open http://localhost:8090 (or your hub host IP on port 8090) in a browser and create the admin account.
  3. Click Add System in the hub dashboard.
  4. Enter /beszel_socket/beszel.sock in the Host / IP field for the local agent.
  5. Copy the public key and token from the dialog.
  6. Paste those values into KEY and TOKEN in docker-compose.yml, then run docker compose up -d to restart the agent.
  7. 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_data at /var/lib/beszel-agent.
  • Keep SYSTEM_NAME optional: When unset, the agent registers using the host’s own system hostname. Set SYSTEM_NAME only 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. Setting DISABLE_SSH: "true" on the hub disables hub-initiated SSH and requires agents to connect via WebSocket. The hub setting defaults to false.
  • Read the key and token from files. The agent supports KEY_FILE and TOKEN_FILE as 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.

ComponentVariableDefaultPurpose
HubAPP_URLUnsetHub URL for notification links and subpath deployments
HubDISABLE_SSHfalseTurns off outgoing SSH connections so agents must connect by WebSocket
AgentLISTEN45876TCP port, literal IP with port, or full Unix socket path for incoming hub connections
AgentHUB_URLUnsetHub URL for outbound agent WebSocket connections
AgentKEY / KEY_FILEUnsetHub ED25519 public key(s) inline (newline-separated) or from a file
AgentTOKEN / TOKEN_FILEUnsetSystem or universal authentication token inline or from a file
AgentDISABLE_SSHfalseDisables the agent’s internal SSH server for WebSocket-only operation
AgentSYSTEM_NAMEUnsetCustom 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 /_/#/logs on the Beszel Hub for information about the connection error.
  • Test TCP reachability in SSH mode. Run telnet <agent-ip> <port> (default port 45876) from another device on the network to test connectivity.
  • Check iptables forwarding on the hub host: If the hub host enforces iptables -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-connect is 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:ro bind mount. Run docker stats on 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.

Sources

  1. Beszel Getting Started Guide
  2. Beszel Hub Installation Guide
  3. Beszel Agent Installation Guide
  4. Beszel Environment Variables Reference
  5. Beszel Security Documentation
  6. Beszel Additional Disks Guide
  7. Beszel Reverse Proxy Guide
  8. Beszel Common Issues Guide

Related

Illustrated title card for the guide: Beszel vs Prometheus and Grafana for Homelab Monitoring

Beszel vs Prometheus and Grafana for Homelab Monitoring

Compare Beszel with Prometheus and Grafana for Linux host and Docker monitoring, then verify your first host metrics on either stack.

Illustrated title card for the guide: Uptime Kuma Setup With SSL Expiry Checks and ntfy Alerts

Uptime Kuma Setup With SSL Expiry Checks and ntfy Alerts

Set up Uptime Kuma in Docker, monitor an HTTPS certificate, choose how early to warn, and verify that alerts reach your ntfy topic.

Illustrated title card for the guide: Prometheus Node Exporter and Grafana Dashboard 1860 Setup

Prometheus Node Exporter and Grafana Dashboard 1860 Setup

Set up Prometheus Node Exporter on Linux, confirm Prometheus is scraping host metrics, then import Grafana dashboard 1860 and troubleshoot empty panels.