Skip to content

How to Self-Host Grafana and Access Your Dashboards from Anywhere

Self-host Grafana on Linux or Docker, connect Prometheus, and access your dashboards from anywhere securely with a Localtonet tunnel. No open ports required.

Summary in your language
In this article 11 sections
📊 Grafana · Prometheus · Self-Hosting · Remote Access · 2026

Build a private monitoring stack, verify host metrics, and share only your dashboard endpoint

Grafana turns monitoring data into useful dashboards, but it needs a data source, persistent storage, and a deliberate access policy. This guide covers native Linux packages and a Linux Docker Compose alternative, with Prometheus and Node Exporter collecting host metrics. We also cover initial access through SSH, dashboard creation, consistent backups, isolated restoration, and public HTTPS access with Localtonet. Keep the monitoring backends private and verify every boundary before publishing Grafana.

🔒 Loopback-only monitoring endpoints 📈 Verified host metrics 🌐 Remote HTTPS dashboard access
A self-hosted Grafana server sends a dashboard through a tunnel to a remote tablet.
Grafana stays on the Linux host while remote browsers reach its login surface through a tunnel.

Understand the monitoring and access architecture

Prometheus scrapes Node Exporter and Grafana queries the stored metrics.
The collection flow is the same for both installation paths. The corrected Linux container example below uses host networking and loopback scrape targets, not exporter container DNS.

Grafana visualizes data; installing it does not automatically collect Linux measurements. Node Exporter exposes host CPU, memory, filesystem, and network counters. Prometheus scrapes those counters and stores time series. Grafana queries Prometheus and stores its own dashboards, users, and configuration separately.

Remote access is another layer. Our Localtonet client runs on the Grafana host and establishes an outbound connection to a relay. An HTTP tunnel forwards a public HTTPS address to 127.0.0.1:3000. Dashboard viewers do not need direct access to Prometheus or Node Exporter.

📊GrafanaServes dashboards and stores application configuration in a persistent SQLite database in this tutorial.
🗄️PrometheusStores scraped time series in its own persistent TSDB directory.
🖥️Node ExporterReads host measurements. Container namespace choices determine what those measurements actually describe.
🌐LocaltonetPublishes the selected Grafana endpoint while its client is connected and the tunnel is running.

For a single Linux host, the Compose example deliberately uses network_mode: host for all three monitoring services. This makes private loopback targets consistent across both paths and gives Node Exporter the host network namespace it needs for host interface metrics. It sacrifices container network isolation, so use it only on a trusted, dedicated host. It is not a Docker Desktop recipe.

ConnectionNative packagesLinux host-network Compose
Browser or Localtonet to Grafana127.0.0.1:3000127.0.0.1:3000
Grafana to Prometheushttp://127.0.0.1:9090http://127.0.0.1:9090
Prometheus to Node Exporter127.0.0.1:9100127.0.0.1:9100
Remote dashboard viewerAssigned public HTTPS URLAssigned public HTTPS URL
Container localhost depends on networking mode

Ordinary bridge-network containers have separate loopback interfaces and use service names such as prometheus for inter-container connections. These examples intentionally share the Linux host network instead. Do not mix bridge-network scrape targets with this configuration.

Scope, prerequisites, and version selection

The native instructions target fresh Ubuntu 24.04 LTS or Debian 12 systems using systemd. The Docker branch assumes an already-provisioned Linux host with maintained Docker Engine and the Compose plugin. If Docker is absent, use Docker's Ubuntu installation instructions or Debian installation instructions first. Rootless Docker and user-namespace remapping require different secret ownership and backup handling and are outside this recipe.

Version validation is a deployment prerequisite

No executed test report or tested Grafana, Prometheus, and Node Exporter version matrix accompanies this guide. We therefore do not label particular releases or image tags as tested. Select maintained versions, record them, and pass the checks below on an isolated host before internet publication. The container configuration refuses to run without explicit image references instead of silently using latest.

Allow capacity for the whole stack, not only Grafana. Two CPU cores and 2 to 4 GB of RAM can be a practical small-lab starting budget, but are not a verified minimum or a capacity guarantee. Prometheus disk requirements depend on active series, retention, and scrape frequency. This example sets 15-day retention; monitor disk growth and leave free space for compaction and backups. Consult Grafana installation requirements and Prometheus storage guidance when sizing a production deployment.

  • Use one installation path on a fresh host. Both use ports 3000, 9090, and 9100.
  • Have sudo access, reliable storage, a separate protected backup destination, and permission to expose the application.
  • Keep inbound monitoring ports blocked by existing network policy during installation and validation.
  • Have SSH access from your workstation and outbound access for packages, images, and the Localtonet client.
sudo apt-get update
sudo apt-get install -y ca-certificates curl wget gnupg openssl \
  iproute2 lsof tar unzip openssh-client

cat /etc/os-release
uname -m

Initial setup on a headless server

A workstation's localhost is not the server's localhost. After starting the monitoring stack, run this on your workstation, replacing the SSH destination with your own authorized account and host:

ssh -N -o ExitOnForwardFailure=yes \
  -L 127.0.0.1:13000:127.0.0.1:3000 \
  -L 127.0.0.1:19090:127.0.0.1:9090 \
  operator@server.example

Verify the server host key through a trusted channel. Leave SSH running, then browse to http://127.0.0.1:13000 for Grafana and http://127.0.0.1:19090/targets for Prometheus. SSH authenticates this temporary connection without publishing either backend. These HTTP setup URLs are used before enabling Grafana's public HTTPS cookie settings.

Option A: Install native packages safely

Grafana comes from its official APT repository; the other packages come from the distribution. Compare the repository setup with Grafana's Debian installation instructions. The commands below assume these services are not already installed. Back up and plan a separate migration for an existing installation.

Prevent package auto-start before configuration

Packages can start services during installation. On this fresh host, mask the relevant units first. Do not remove an administrator's pre-existing masks without understanding them.

sudo systemctl mask grafana-server.service prometheus.service \
  prometheus-node-exporter.service

sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://apt.grafana.com/gpg.key \
  | gpg --dearmor \
  | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
sudo chmod 644 /etc/apt/keyrings/grafana.gpg

echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" \
  | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update
apt-cache policy grafana prometheus prometheus-node-exporter

Review the offered versions before installing. This package command selects repository candidates, not a fixed tested release. Record the resolved versions for your restore and upgrade plan.

sudo apt-get install -y grafana prometheus prometheus-node-exporter
dpkg-query -W grafana prometheus prometheus-node-exporter \
  | tee native-versions.txt

Set Grafana's local listener and preserve its encryption key

Edit existing sections in /etc/grafana/grafana.ini, removing comment prefixes from active settings. Do not append duplicate sections. Before first startup, generate a random secret with openssl rand -hex 32 and privately put it in secret_key. Keep the file readable by Grafana but not other ordinary users.

[server]
http_addr = 127.0.0.1
http_port = 3000

[security]
secret_key = REPLACE_WITH_YOUR_GENERATED_SECRET

[users]
allow_sign_up = false

[auth.anonymous]
enabled = false
sudo chown root:grafana /etc/grafana/grafana.ini
sudo chmod 640 /etc/grafana/grafana.ini

Grafana's secret key protects stored secrets such as data-source credentials. Preserve it with the database and configuration; replacing it is not a password-reset procedure.

Configure Prometheus and service arguments

Back up /etc/prometheus/prometheus.yml, then replace it with the following configuration for this fresh, single-host stack. The same file is used in the Docker path.

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ["127.0.0.1:9090"]
  - job_name: node
    static_configs:
      - targets: ["127.0.0.1:9100"]
sudo systemctl cat prometheus
sudo systemctl cat prometheus-node-exporter
sudo editor /etc/default/prometheus
sudo editor /etc/default/prometheus-node-exporter

Inspect each unit's ExecStart and EnvironmentFile. For packages that consume ARGS from these defaults files, retain existing arguments, including configuration paths, storage paths, and collector options. Add or replace each relevant flag exactly once:

  • Prometheus: --web.listen-address=127.0.0.1:9090 and --storage.tsdb.retention.time=15d.
  • Node Exporter: --web.listen-address=127.0.0.1:9100.

For example, an existing ARGS="--some-existing-option" must keep that option when the listener flag is added. Do not overwrite the entire value with only a listener flag. If the package does not consume these defaults files, stop here and adapt its documented unit configuration rather than assuming these edits work.

Validate, explicitly restart, and inspect

promtool check config /etc/prometheus/prometheus.yml

sudo systemctl unmask grafana-server.service prometheus.service \
  prometheus-node-exporter.service
sudo systemctl daemon-reload
sudo systemctl enable grafana-server prometheus prometheus-node-exporter
sudo systemctl restart prometheus-node-exporter prometheus grafana-server

sudo systemctl status grafana-server prometheus prometheus-node-exporter \
  --no-pager
ps -ww -C prometheus -C prometheus-node-exporter -o args=
sudo ss -lntp | grep -E ':(3000|9090|9100)\b'

All three listeners must be on 127.0.0.1, not 0.0.0.0, a LAN address, or [::]. Explicit restart matters: enable --now does not restart an already-running service after configuration changes. Complete the verification section before creating a tunnel.

Use the SSH-forwarded Grafana URL for initial login. A fresh default installation normally uses admin/admin; immediately change the password. If credentials were configured differently, use those instead. Never publish an uninitialized administrator account.

Option B: Use Linux host-network Docker Compose

Native Linux services and Docker containers packaging the same monitoring components.
Packaging differs, but the examples now use the same loopback addresses. The Compose configuration below is authoritative for namespace and listener settings.

This branch starts with working, rootful Docker Engine and Compose. Docker access grants substantial host privileges. Validate versions and create the project:

docker version
docker compose version
mkdir -p ~/grafana-stack/secrets
cd ~/grafana-stack
chmod 700 secrets

Select pinned images and prepare readable, protected secrets

Create .env with explicit, reviewed version tags or immutable digests. Replace all three placeholder values before continuing; no version here is claimed to have passed testing.

GRAFANA_IMAGE=grafana/grafana:REPLACE_WITH_REVIEWED_VERSION
PROMETHEUS_IMAGE=prom/prometheus:REPLACE_WITH_REVIEWED_VERSION
NODE_EXPORTER_IMAGE=quay.io/prometheus/node-exporter:REPLACE_WITH_REVIEWED_VERSION

Generate the administrator password and a separate Grafana encryption key without writing them into Compose YAML or shell command arguments:

umask 077
openssl rand -hex 24 > secrets/admin_password
openssl rand -hex 32 > secrets/secret_key
chmod 600 .env

Compose file-backed secrets are mounted files, not an automatic ownership conversion. Determine the UID and GID from the selected Grafana image, then give only that identity read permission. Run the following after replacing the image placeholders:

set -a
. ./.env
set +a
docker pull "$GRAFANA_IMAGE"
GF_UID=$(docker run --rm --entrypoint sh "$GRAFANA_IMAGE" -c 'id -u')
GF_GID=$(docker run --rm --entrypoint sh "$GRAFANA_IMAGE" -c 'id -g')
test "$GF_UID" -ne 0 || { echo "Select a non-root Grafana image"; exit 1; }
sudo chown "$GF_UID:$GF_GID" secrets/admin_password secrets/secret_key
sudo chmod 400 secrets/admin_password secrets/secret_key

The private parent directory stays owned by your operator account with mode 700; the rootful Docker daemon can mount the individual files. Do not make secrets world-readable or run Grafana as root to fix permissions. Exclude secrets/ and backup material from version control.

Create configuration and start the stack

Save the Prometheus YAML from the native section as prometheus.yml in this project, with mode 644. Create compose.yml:

services:
  grafana:
    image: ${GRAFANA_IMAGE:?Set a pinned Grafana image in .env}
    network_mode: host
    restart: unless-stopped
    environment:
      GF_SERVER_HTTP_ADDR: "127.0.0.1"
      GF_SERVER_HTTP_PORT: "3000"
      GF_SECURITY_ADMIN_USER: admin
      GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/admin_password
      GF_SECURITY_SECRET_KEY__FILE: /run/secrets/secret_key
      GF_USERS_ALLOW_SIGN_UP: "false"
      GF_AUTH_ANONYMOUS_ENABLED: "false"
    secrets:
      - admin_password
      - secret_key
    volumes:
      - grafana_data:/var/lib/grafana

  prometheus:
    image: ${PROMETHEUS_IMAGE:?Set a pinned Prometheus image in .env}
    network_mode: host
    restart: unless-stopped
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.path=/prometheus
      - --storage.tsdb.retention.time=15d
      - --web.listen-address=127.0.0.1:9090
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus_data:/prometheus

  node-exporter:
    image: ${NODE_EXPORTER_IMAGE:?Set a pinned Node Exporter image in .env}
    network_mode: host
    pid: host
    restart: unless-stopped
    command:
      - --path.rootfs=/host
      - --web.listen-address=127.0.0.1:9100
    volumes:
      - /:/host:ro,rslave

secrets:
  admin_password:
    file: ./secrets/admin_password
  secret_key:
    file: ./secrets/secret_key

volumes:
  grafana_data:
  prometheus_data:

This follows the essential host-network, host-PID, and rootfs-mount pattern described by the Node Exporter container deployment documentation. The host root mount is security-sensitive even when read-only. Host networking lets the exporter see host network interfaces; the explicit listener keeps its HTTP endpoint private. Some collectors remain platform-dependent, so verify the metrics you actually need.

docker compose config
docker compose pull
docker compose run --rm --no-deps --entrypoint sh grafana \
  -c 'id; test -r /run/secrets/admin_password && test -r /run/secrets/secret_key'
docker compose run --rm --no-deps --entrypoint promtool prometheus \
  check config /etc/prometheus/prometheus.yml
docker compose up -d
docker compose ps
docker compose logs --tail=100

Read the generated initial password privately with sudo cat secrets/admin_password and log in through SSH forwarding. The initial administrator password setting only initializes a new database. Editing this file does not rotate the password of an administrator already stored in SQLite; use Grafana's account-management or documented password-reset process.

Docker port isolation requires more than a socket listing

This configuration has no published Docker ports: services bind directly to host loopback. If you redesign it with bridge networking, inspect published mappings as well as sockets. Docker documents that releases older than 28.0.0 could allow same-layer-2 peers to reach ports published to localhost. Use a maintained Engine and read the port-publishing security notes. Always test from another machine.

Connect Prometheus and build a complete host dashboard

Grafana data-source configuration alongside a host metrics dashboard.
Use http://127.0.0.1:9090 for both configurations in this guide, then build panels from verified exporter metrics.

In Grafana, open Connections → Data sources → Add new data source and choose Prometheus. Set the name to Host Prometheus and the server URL to http://127.0.0.1:9090. Select Save & test. This checks the connection from the Grafana server, not from your browser.

In Explore, select that data source and query up. After two scrape intervals, expect values of 1 for both jobs. Wait at least five minutes before interpreting the five-minute rate panels below.

  1. Open Dashboards → New → New dashboard, then add a visualization.
  2. Select Host Prometheus and switch the Prometheus query editor to code mode.
  3. Paste the CPU query below, select a Time series visualization, and title it Host CPU busy.
  4. Under standard options, set the unit to Percent (0-100), minimum 0, and maximum 100. Apply or return to the dashboard.
  5. Add memory and network panels using the other queries and units below.
  6. Set the dashboard time range to Last 1 hour and refresh interval to 30 seconds.
  7. Select Save dashboard, name it Linux host overview, choose a folder, and save. Reload it to confirm persistence.

CPU busy percentage

100 * (1 - avg by (instance) (
  rate(node_cpu_seconds_total{job="node",mode="idle"}[5m])
))

This averages across logical CPUs and reports non-idle time as a percentage. Expect a low value on an idle host and an increase during normal activity. It is not process-level attribution.

Memory used percentage

100 * (1 -
  node_memory_MemAvailable_bytes{job="node"}
  / node_memory_MemTotal_bytes{job="node"}
)

Use Percent (0-100), minimum 0, maximum 100, and title Host memory used. Available memory accounts for reclaimable memory, so this is more useful than treating every cached byte as unavailable.

Received network traffic by interface

rate(node_network_receive_bytes_total{job="node",device!="lo"}[5m])

Use bytes/sec, minimum 0, title Network receive, and legend {{device}}. Inspect interface labels before filtering further. Docker bridges and virtual interfaces may appear alongside physical interfaces; summing them can double-count traffic. On a quiet host, zero or near-zero traffic is normal.

You can later import content from the Grafana dashboard library. Review required labels, recording rules, plugins, and variables first. A community dashboard is not proof that your exporter is collecting the intended host metrics.

Verify health, host identity, and network isolation

Check every service locally

curl -fsS http://127.0.0.1:3000/api/health
curl -fsS http://127.0.0.1:9090/-/ready
curl -fsS http://127.0.0.1:9100/metrics -o /tmp/node-metrics.txt
sudo ss -lntp | grep -E ':(3000|9090|9100)\b'

Expect Grafana's database health to be OK, Prometheus to report readiness, and exporter metrics to download. On the Prometheus targets page, both jobs should be healthy. A successful up query proves scrape reachability, not correctness of host attribution.

Compare exporter output with the host

uname -r
hostname
ip -br link
cat /proc/net/dev
grep '^node_uname_info' /tmp/node-metrics.txt
grep '^node_network_receive_bytes_total' /tmp/node-metrics.txt
grep '^node_filesystem_size_bytes' /tmp/node-metrics.txt

Compare kernel information, interface names, filesystem mount points, and plausible sizes. A container's hostname label can differ because UTS namespaces are separate; do not use that label alone to identify the host. Inspect the container's configured namespaces:

docker inspect "$(docker compose ps -q node-exporter)" \
  --format 'network={{.HostConfig.NetworkMode}} pid={{.HostConfig.PidMode}}'

docker inspect "$(docker compose ps -q grafana)" \
  --format 'network={{.HostConfig.NetworkMode}} bindings={{json .HostConfig.PortBindings}}'

Expect network=host pid=host for the exporter and no port bindings for Grafana. Generate a small, authorized network transfer on the host, then compare the relevant interface's receive-counter increase in /proc/net/dev with the exporter counter and the dashboard after several scrapes. Values will differ slightly because sampling times differ. Missing host interfaces or unrelated counters require investigation before trusting the dashboard.

Test from another machine before publication

From a different authorized LAN machine, try each monitoring port using the server's LAN address:

curl --connect-timeout 3 http://SERVER_LAN_IP:3000/api/health
curl --connect-timeout 3 http://SERVER_LAN_IP:9090/-/ready
curl --connect-timeout 3 http://SERVER_LAN_IP:9100/metrics

All should fail to connect. Repeat for reachable IPv6 addresses and other relevant interfaces. A firewall may cause timeouts rather than refusals. Do not rely on ss alone, particularly after changing Docker networking. Stop and correct unintended exposure before continuing.

Install Localtonet and configure public HTTPS access

A Localtonet tunnel forwards a remote browser connection to Grafana on port 3000.
Only the Grafana endpoint is selected as the tunnel target. Monitoring backends remain on loopback.

With Localtonet, you do not need inbound router port forwarding, VPN setup, or a public IP address to expose this endpoint. This does not bypass authorization or organizational policy. The public URL exposes Grafana's login surface, and Grafana remains responsible for user authentication and permissions.

Preferred Linux installation: packaged service and protected token file

Our download page provides DEB packages for x64 and ARM64. They require systemd 247 or newer and OpenSSL 3, including Debian 12 and Ubuntu 22.04 or later. Download the package matching uname -m to the Grafana host. The documented package sequence has three steps:

1

Install the downloaded package

From its directory, run sudo apt install ./localtonet-linux-x64.deb. For ARM64, use localtonet-linux-arm64.deb instead.

2

Set and validate the device token

Edit /etc/localtonet/auth-token as root. Replace DUMMY_AUTH_TOKEN with your device-specific token on one line, protect the file, and check the configuration.

3

Start the packaged service

After validation succeeds, enable and start the existing systemd service. Inspect its logs and confirm the device is connected.

sudo editor /etc/localtonet/auth-token
sudo chmod 600 /etc/localtonet/auth-token
sudo localtonet --headless \
  --authtoken-file /etc/localtonet/auth-token --check-config
sudo systemctl enable --now localtonet.service
sudo systemctl status localtonet.service --no-pager
sudo journalctl -u localtonet.service -n 100 --no-pager

Do not run --install-service over the packaged service. For package upgrades, install the new package and explicitly run sudo systemctl restart localtonet. This HTTP workflow does not require the separate VPN service.

Standalone installation is a different path

If you deliberately choose the standalone Linux build instead of a DEB package, the official quick installer detects the platform and installs /usr/local/bin/localtonet. Download and review the script before running it:

curl -fsSL https://localtonet.com/install.sh -o localtonet-install.sh
less localtonet-install.sh
sh localtonet-install.sh

The standalone client can prompt for the token. The documented standalone service commands are sudo localtonet --install-service --authtoken <YOUR_TOKEN> and sudo localtonet --start-service --authtoken <YOUR_TOKEN>. Token arguments can enter shell history or process listings, so prefer the packaged protected-file workflow above. The standalone installer creates /etc/systemd/system/localtonet.service; do not mix standalone and package-managed service ownership.

Configure the HTTP tunnel without assuming a fixed dashboard wizard

Use our HTTP tunnel documentation alongside the current dashboard. The supplied evidence establishes the settings below, but not a verified numbered dashboard wizard; these are a configuration checklist, not an asserted eight-step canonical sequence.

  • Use an HTTP tunnel, with a Process Type of Random Sub Domain, Custom Sub Domain, or Custom Domain where available.
  • Select the AuthToken for the device running Grafana and choose a currently available relay server.
  • Set the local target IP to 127.0.0.1 and port to 3000.
  • Create the configuration and explicitly press Start. Creation alone does not start a tunnel.
  • Record the assigned HTTPS URL. Available process types, domains, and relay choices can vary; follow current custom-domain DNS guidance rather than guessing DNS records.

Set Grafana's public URL and secure cookies

After learning the assigned address, stop the tunnel while finalizing Grafana. Replace the example hostname below with the exact public HTTPS hostname, including the trailing slash in the root URL. Keep the upstream protocol HTTP because Grafana is reached on local loopback; the browser-facing address is HTTPS.

For native packages, edit the existing sections of /etc/grafana/grafana.ini, preserving your secret key:

[server]
protocol = http
http_addr = 127.0.0.1
http_port = 3000
root_url = https://YOUR_ASSIGNED_HOSTNAME/

[security]
cookie_secure = true
cookie_samesite = lax
sudo systemctl restart grafana-server

For Compose, add these entries to Grafana's existing environment map:

GF_SERVER_PROTOCOL: "http"
GF_SERVER_ROOT_URL: "https://YOUR_ASSIGNED_HOSTNAME/"
GF_SECURITY_COOKIE_SECURE: "true"
GF_SECURITY_COOKIE_SAMESITE: "lax"
docker compose up -d grafana

Compose restart alone does not apply changed environment variables. See Grafana's configuration reference for URL, cookie, and live-connection settings.

Restart the tunnel and test from a separate network. Sign in, open the saved dashboard, refresh it, sign out, then confirm a fresh private-browser session cannot see dashboards without authentication. Check that redirects stay on the assigned HTTPS origin and that the session cookie has the Secure flag. Once secure cookies are enabled, use the HTTPS URL for normal login rather than the temporary HTTP SSH-forwarded URL.

If a feature uses Grafana Live, inspect browser developer tools for the /api/live/ws connection and confirm a successful WebSocket upgrade when that feature is active. Standard Prometheus dashboard polling does not itself prove Live works. Investigate origin errors, root URL mismatch, or transport failure without allowing arbitrary origins. Update Grafana's root URL whenever the public address changes.

Apply least privilege before sharing

Use unique administrator credentials and ordinary Viewer accounts for dashboard-only access. Keep anonymous access and unwanted sign-up disabled. Review public dashboards, snapshots, share links, plugins, alert destinations, and data-source credentials. A public snapshot or sharing mode may expose data independently of normal login.

Only tunnel Grafana. Prometheus can support TLS and basic authentication, but is not a substitute for Grafana's user and role model. Exporter metrics reveal infrastructure details and should not be public. Treat Localtonet device tokens, Grafana secret keys, and backups as secrets.

Self-hosting does not mean that no data leaves the host: remote browsers receive dashboard data, and configured notifications, plugins, renderers, or external sources can contact other services. Inventory those integrations. Stop the tunnel when remote access is no longer required; the client, tunnel, and Grafana process have separate lifecycles.

Consistent backups, isolated restoration, and upgrades

This guide uses Grafana's default SQLite storage and a local Prometheus TSDB. Use a cold backup: stop writers, copy all data and configuration, then restart. Do not copy only a live grafana.db or selected Prometheus blocks. The method trades downtime for a straightforward consistent restore point.

Native cold backup

Confirm paths from the active configuration first. The following procedure assumes Grafana data at /var/lib/grafana and Prometheus storage under /var/lib/prometheus. If your package uses another location, replace it throughout. Include any systemd overrides, provisioning files, certificates, and external secret-key providers you added.

sudo install -d -m 700 /srv/monitoring-backups
BACKUP="/srv/monitoring-backups/native-$(date -u +%Y%m%dT%H%M%SZ).tar.gz"

sudo systemctl stop grafana-server prometheus
sudo tar --numeric-owner -czpf "$BACKUP" -C / \
  etc/grafana etc/prometheus \
  etc/default/prometheus etc/default/prometheus-node-exporter \
  var/lib/grafana var/lib/prometheus
sudo chmod 600 "$BACKUP"
sudo tar -tzf "$BACKUP" > /dev/null
sudo systemctl start prometheus grafana-server

Check each command's exit status. If archiving fails, do not declare the backup successful. Copy the version manifest and protected archive to separate, access-controlled storage. Save any relevant /etc/systemd/system overrides separately.

Compose cold backup with explicit volume identification

This procedure assumes the rootful local Docker volume driver. Run it from ~/grafana-stack. Inspect mounts rather than guessing project-prefixed volume names:

G_VOL=$(docker inspect "$(docker compose ps -q grafana)" \
  --format '{{range .Mounts}}{{if eq .Destination "/var/lib/grafana"}}{{.Name}}{{end}}{{end}}')
P_VOL=$(docker inspect "$(docker compose ps -q prometheus)" \
  --format '{{range .Mounts}}{{if eq .Destination "/prometheus"}}{{.Name}}{{end}}{{end}}')
test -n "$G_VOL" && test -n "$P_VOL" || exit 1
docker volume inspect "$G_VOL" "$P_VOL"

G_PATH=$(docker volume inspect "$G_VOL" --format '{{.Mountpoint}}')
P_PATH=$(docker volume inspect "$P_VOL" --format '{{.Mountpoint}}')
B="/srv/monitoring-backups/compose-$(date -u +%Y%m%dT%H%M%SZ)"
sudo install -d -m 700 "$B"

docker compose stop grafana prometheus
sudo tar --numeric-owner -czpf "$B/grafana-data.tar.gz" -C "$G_PATH" .
sudo tar --numeric-owner -czpf "$B/prometheus-data.tar.gz" -C "$P_PATH" .
sudo tar --numeric-owner -czpf "$B/config.tar.gz" \
  compose.yml .env prometheus.yml secrets
sudo chmod 600 "$B/"*.tar.gz
sudo tar -tzf "$B/grafana-data.tar.gz" > /dev/null
sudo tar -tzf "$B/prometheus-data.tar.gz" > /dev/null
docker compose start prometheus grafana

Record image digests with docker image inspect and retain those images or ensure they remain retrievable. Back up all provisioning or custom configuration mounts added later. The secret-key file must travel with the database, although protected key escrow may be stored separately. The initial password file is not authoritative for a password changed inside Grafana.

Restore into an isolated native VM

Use a disposable VM with no Localtonet client, no public exposure, and outbound notification access blocked. Install the same package versions with services masked as above. Transfer the archive securely, stop the services, and extract the backup:

sudo systemctl stop grafana-server prometheus
sudo tar --numeric-owner -xzpf /secure/native-backup.tar.gz -C /
sudo chown -R grafana:grafana /var/lib/grafana
sudo chown -R prometheus:prometheus /var/lib/prometheus
sudo chown root:grafana /etc/grafana/grafana.ini
sudo chmod 640 /etc/grafana/grafana.ini

These ownership adjustments account for different package account IDs on the restore VM. Review any additional configuration ownership individually. Preserve the restored secret key. For this isolated test only, set Grafana's root URL to http://127.0.0.1:13000/ and cookie_secure = false, then access it through the SSH forwarding command. Unmask and restart services after reviewing all restored configuration. Never copy these test-only HTTP settings back to the public deployment.

Restore Compose data into a separate Linux VM

Use a separate VM because host networking makes an alternate Compose project on the production host conflict on the same ports. Provision the same Docker mode, copy the backup securely, and restore the project:

mkdir -p ~/grafana-restore
cd ~/grafana-restore
sudo tar --numeric-owner -xzpf /secure/config.tar.gz
sudo chown "$(id -u):$(id -g)" .
sudo chown "$(id -u):$(id -g)" compose.yml .env prometheus.yml secrets
chmod 700 secrets
chmod 600 .env

Keep individual secret-file ownership as restored, and verify it matches the pinned image's non-root UID. Set the test root URL and cookie environment values to the isolated HTTP values described above. Do not change the restored encryption key. Create containers without starting them and discover their new volumes:

docker compose pull
docker compose create

G_VOL=$(docker inspect "$(docker compose ps -aq grafana)" \
  --format '{{range .Mounts}}{{if eq .Destination "/var/lib/grafana"}}{{.Name}}{{end}}{{end}}')
P_VOL=$(docker inspect "$(docker compose ps -aq prometheus)" \
  --format '{{range .Mounts}}{{if eq .Destination "/prometheus"}}{{.Name}}{{end}}{{end}}')
G_PATH=$(docker volume inspect "$G_VOL" --format '{{.Mountpoint}}')
P_PATH=$(docker volume inspect "$P_VOL" --format '{{.Mountpoint}}')

sudo tar --numeric-owner -xzpf /secure/grafana-data.tar.gz -C "$G_PATH"
sudo tar --numeric-owner -xzpf /secure/prometheus-data.tar.gz -C "$P_PATH"
docker compose up -d
docker compose logs --tail=100

Use fresh volumes, not a merge with previously running data. Numeric ownership is appropriate here because the restore uses the same pinned images and Docker identity model. If those differ, resolve ownership before startup rather than making directories world-writable.

Post-restore acceptance checks

  • Repeat listener, health, and target checks. The restored stack must not be publicly reachable.
  • Sign in with the password stored in the restored database, not necessarily the initial secret-file password.
  • Confirm saved dashboards, users, data sources, and any configured credentials work.
  • Query a historical time window from before the backup. This checks restored Prometheus history, not just new scrapes.
  • Confirm current scrapes arrive from the restore host; new metrics will describe that VM.
  • Check logs for SQLite migrations, decryption errors, TSDB corruption, and permission failures.

Disable restored alerting and notification routes before allowing outbound traffic. Record restore duration and results. A backup is not proven by an archive listing alone.

Routine operation and upgrades

For native services, use systemctl status, systemctl restart, and journalctl -u SERVICE. For Compose, use docker compose ps, logs --tail=100, stop, and start. Recreating containers preserves named volumes; docker compose down -v deletes them.

Before upgrading, review release notes, create a cold backup, and test the upgrade on the restored isolated copy. Update pinned image references or selected package versions deliberately. Re-run health, historical-data, login/logout, dashboard, and public HTTPS checks afterward. Do not assume a database migration can be undone simply by starting an older binary.

Troubleshoot the failing boundary

A service does not start or a port is occupied

sudo ss -lntp | grep -E ':(3000|9090|9100)\b'
sudo lsof -iTCP:3000 -sTCP:LISTEN
sudo journalctl -u grafana-server -u prometheus -n 100 --no-pager

For Docker, use docker compose ps -a and docker compose logs --tail=200. Check configuration syntax, storage space, secret readability, and conflicting native services. Do not fix a conflict by binding a backend to every interface.

Grafana reports an unreadable secret or storage permission error

Run the Compose secret-readability check again using the pinned image. Confirm the file's numeric owner matches that image's non-root user and that you are using rootful Docker without remapping. For storage, inspect the configured path and ownership. Do not run Grafana as root or use world-writable permissions.

Prometheus is down or panels are empty

Read the scrape error on /targets, then test the exporter locally. For both tutorial paths the target is 127.0.0.1:9100. Confirm host networking if using Docker. Query up, then raw memory or network metrics. If those work, inspect the panel's data source, time range, labels, and five-minute rate window. Imported dashboards may expect different job names or recording rules.

The tunnel fails, redirects incorrectly, or loses login

First check http://127.0.0.1:3000/api/health on the server. Then confirm the selected Localtonet device is connected, its target is correct, and the tunnel is started. Inspect journalctl -u localtonet when using service mode. For login failures, verify the current public root URL, HTTPS cookie settings, and browser origin. Recreate the Grafana container after environment changes; restarting an unchanged container is insufficient.

The stack does not recover after reboot

Check systemd enablement for native services and the Localtonet client. For Compose, verify Docker started and containers are running. restart: unless-stopped does not restart an intentionally stopped container or replace health monitoring. A connected client still needs a started tunnel, and a started tunnel still needs a healthy Grafana target.

Frequently asked questions

Does installing Grafana collect host metrics automatically?

No. Node Exporter exposes measurements, Prometheus scrapes and stores them, and Grafana queries Prometheus. Verify all three components independently.

Why does this Docker example use localhost for Prometheus?

All three containers intentionally use Linux host networking. With ordinary bridge networking, Grafana would instead use the Prometheus service name, and exporter host-network collection would need a separately designed private scrape path.

Will container restarts delete dashboards?

Not when Grafana uses its persistent named volume. Volume deletion, including docker compose down -v, can remove the database. Maintain protected, restore-tested backups.

Does editing the administrator password file change an existing password?

No. The initial password setting initializes a new Grafana database. Change an existing account password through Grafana's supported account-management or recovery procedure.

Does Localtonet make Grafana private?

The local listener remains restricted, but the assigned HTTPS address is publicly reachable while the client is connected and the tunnel is running. Keep authentication enabled and use least-privilege accounts. Standard HTTP tunneling is not a private mesh VPN.

Should Prometheus also have a public tunnel?

Usually not. Dashboard viewers only need Grafana. Keep Prometheus and Node Exporter private unless you have a separately justified and secured remote-backend requirement.

Why does creating a tunnel not make its URL available?

Creation records configuration. You must press Start, keep the selected client connected, and keep Grafana reachable at the configured target.

Can I use other data sources, and is self-hosting cost-free?

Grafana supports other metrics, logs, traces, and database sources, each with separate security and storage requirements. Grafana OSS is open-source software, but infrastructure, backups, electricity, networking, maintenance, and optional licensed services can still have costs.

Publish your verified Grafana endpoint with Localtonet

Build and restore-test the monitoring stack first. Then point an HTTP tunnel at 127.0.0.1:3000, configure Grafana's public HTTPS URL, and verify authenticated access from another network.

Get Started with Localtonet →

Corrections & updates

Substantive changes approved by the Localtonet editorial team are listed transparently below.

Reviewed and updated for accuracy and completeness.

Reviewed and updated for accuracy and completeness.

Localtonet is a secure multi-protocol tunneling and proxy platform designed to expose localhost, devices, private services, and AI agents to the public internet supporting HTTP/HTTPS tunnels, TCP/UDP forwarding, mobile proxy infrastructure, file server publishing, latency-optimized game connectivity, and developer-ready AI agent endpoint exposure from a single unified control plane.

Support