Ubuntu 24.04 LTS
Install Grafana OSS from the official stable APT repository. Run the following commands with a sudo-enabled account.
Install Grafana
sudo apt update
sudo apt install -y ca-certificates wget curl
sudo install -d -m 0755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key
sudo chmod 0644 /etc/apt/keyrings/grafana.asc
echo 'deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main' | sudo tee /etc/apt/sources.list.d/grafana.list > /dev/null
sudo apt update
apt-cache policy grafana
sudo apt install -y grafana
dpkg-query -W -f='${Package} ${Version}\n' grafana
The .asc file contains the ASCII-armored signing key and does not need gpg --dearmor. The grafana package installs OSS; grafana-enterprise is a separate package choice. See the official Ubuntu installation guide.
The repository command replaces this dedicated source file instead of appending another entry. If Grafana was previously configured in a different .list or .sources file, reconcile those entries before running apt update.
Configure Local Access
Back up the configuration and edit it:
sudo cp -a /etc/grafana/grafana.ini "/etc/grafana/grafana.ini.bak.$(date +%Y%m%d-%H%M%S)"
sudo nano /etc/grafana/grafana.ini
Update the existing [server] section. Remove the leading semicolon from the settings you change; do not append a duplicate section.
[server]
protocol = http
http_addr = 127.0.0.1
http_port = 3000
domain = localhost
root_url = http://localhost:3000/
This example listens only on the server’s loopback interface. http_addr controls the listening address; domain does not create a DNS record, and root_url defines the URL users access. See the Grafana configuration reference.
Start the Service
sudo systemctl daemon-reload
sudo systemctl enable --now grafana-server
sudo systemctl restart grafana-server
sudo systemctl status grafana-server --no-pager
The restart also applies the configuration if the package was already running.
sudo ss -ltnp 'sport = :3000'
curl --fail --silent --show-error http://127.0.0.1:3000/api/health
The health response should report "database": "ok". This checks Grafana’s own database connection, not the health of external data sources. See the health API.
First Login
On the server, open http://localhost:3000.
For a remote server, run an SSH tunnel from your workstation, replacing the account and address:
ssh -N -L 3000:127.0.0.1:3000 username@192.168.1.50
Keep the tunnel open and visit http://localhost:3000 on the workstation. Local port 3000 must be available.
For a fresh installation, sign in with username admin and password admin, then set a new password. Existing installations retain their configured credentials. See Sign in to Grafana.
Optional: Allow LAN Access
To access Grafana directly from other computers on a trusted LAN, edit the same [server] section:
sudo nano /etc/grafana/grafana.ini
[server]
protocol = http
http_addr = 0.0.0.0
http_port = 3000
domain = 192.168.1.50
root_url = http://192.168.1.50:3000/
Replace 192.168.1.50 with the server’s LAN address. 0.0.0.0 listens on all IPv4 interfaces; alternatively, bind to a specific IP assigned to the server. Do not use a hostname or an unassigned public IP as http_addr.
sudo systemctl restart grafana-server
sudo systemctl status grafana-server --no-pager
curl --fail --silent --show-error http://192.168.1.50:3000/api/health
If UFW is already active, allow the required client subnet:
sudo ufw allow from 192.168.1.0/24 to any port 3000 proto tcp
sudo ufw status
Replace the subnet to match your network, then open http://192.168.1.50:3000 from a client computer.
For a DNS name, create a record pointing to the server and update domain and root_url accordingly. This example uses HTTP. For access over an untrusted network, configure HTTPS or use the SSH tunnel above.
Add a Data Source
Grafana needs a data source, such as Prometheus, to display your metrics. Installing Grafana alone does not collect host metrics.
- Open Connections > Add new connection.
- Choose the data source type and select Add new data source.
- Enter its URL and any required authentication settings.
- Select Save & test.
Use an address reachable from the Grafana server. For example, http://localhost:9090 refers to Prometheus on that server, not on your browser’s computer. See Data source management.
After the connection succeeds, create a dashboard or use a compatible template from the dashboard catalog linked above. Dashboard queries must match the selected data source and the metrics it contains.
Service Management
sudo systemctl restart grafana-server
sudo systemctl stop grafana-server
sudo systemctl start grafana-server
sudo systemctl is-enabled grafana-server
sudo journalctl -u grafana-server -n 100 --no-pager
sudo journalctl -u grafana-server -f
Restart Grafana after changing grafana.ini. Editing this file does not require systemctl daemon-reload; that command is needed when the systemd unit changes.
Troubleshooting
| Symptom | Check |
|---|---|
APT reports conflicting Signed-By values |
Look for duplicate Grafana repository entries referencing different key files. |
| Service fails to bind | Check whether port 3000 is occupied and whether http_addr exists on the server. |
| Browser cannot connect | Check service status, listening address, SSH tunnel, and firewall rules. |
| Redirect points to the wrong host | Set root_url to the URL used by clients, including the port when required. |
| Configuration changes have no effect | Remove comment semicolons, restart the service, and check for GF_* environment overrides. |
| Dashboard has no data | Test the data source, check its queries, and adjust the dashboard time range. |