If you’ve ever set up monitoring for your servers or applications, you’ve probably heard about Grafana.
It’s the de facto open-source visualization and dashboard tool for time-series data — capable of turning raw metrics into beautiful and insightful charts.
In this article, I’ll walk you through how to install Grafana on Linux, configure it properly, and deal with common problems that many sysadmins hit along the way.
This guide is written with real-world experience, blending tips from the official documentation and years of self-hosting tinkering.
1. Prerequisites
You’ll need:
- A Linux machine — Ubuntu 22.04 LTS, Debian 11+, or CentOS 8 / Rocky Linux 9.
- A superuser or user with sudo privileges.
- At least 512 MB of RAM and 1 CPU core (Grafana is lightweight).
- Internet access to fetch the repository and packages.
Optionally:
- A domain name (for example: grafana.yourdomain.com)
- Nginx/Apache if you want to enable HTTPS later.
2. Update Your System
Before any installation, ensure your system packages are up to date:
# Debian/Ubuntu
# apt update && sudo apt upgrade -y
# or
# dnf update -y # CentOS/RHEL/Rocky
3. Install Grafana (from the Official Repository)
Grafana provides an official APT and YUM repository. Always use it to get security and feature updates.
For Debian / Ubuntu:
# apt install -y software-properties-common apt-transport-https wget # wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - # echo "deb https://packages.grafana.com/oss/deb stable main" | \ # tee /etc/apt/sources.list.d/grafana.list # apt update # apt install grafana -y
For CentOS / Rocky / RHEL:
# tee /etc/yum.repos.d/grafana.repo <<EOF [grafana] name=Grafana OSS baseurl=https://packages.grafana.com/oss/rpm repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packages.grafana.com/gpg.key EOF # dnf install grafana -y
4. Start and Enable the Service
Once installation completes, start and enable Grafana to run on boot:
# systemctl daemon-reload # systemctl enable grafana-server # systemctl start grafana-server
Check status:
# systemctl status grafana-server
You should see Active: running.
5. Access the Grafana Web Interface
Grafana listens on port 3000 by default.
Open your browser and visit:
http://<your_server_ip>:3000
Login with the default credentials:
Username: admin
Password: admin
You’ll be asked to change the password — do it immediately for security.
6. Configure Grafana Basics
Configuration file location:
/etc/grafana/grafana.ini
Common settings to edit:
- Port:
http_port = 8080
- Root URL (for reverse proxy):
root_url = https://grafana.yourdomain.com/
- Database: (change from SQLite to MySQL/PostgreSQL if desired)
[database] type = mysql host = 127.0.0.1:3306 name = grafana user = grafana password = supersecret_password582?255!#
Restart Grafana after making changes:
# systemctl restart grafana-server
7. Optional – Secure Grafana with HTTPS and Reverse Proxy
If Grafana is public-facing, always use HTTPS.
Install Nginx and Certbot:
# apt install nginx certbot python3-certbot-nginx -y # certbot --nginx -d grafana.yourdomain.com
This automatically sets up SSL certificates and redirects traffic from HTTP → HTTPS.
8. Add a Data Source
Once logged in:
-
Go to Connections → Data Sources → Add data source
-
Choose Prometheus, InfluxDB, Loki, or your preferred backend
-
Enter the connection URL (e.g., http://localhost:9090)
-
Click “Save & Test”
If successful, you can start creating dashboards!
9. Troubleshooting Common Grafana Installation Issues
Even the smoothest installs sometimes go wrong.
Here are real-world fixes for typical problems sysadmins face:
| Problem | Likely Cause | Fix |
|---|---|---|
| Service won’t start | Misconfigured grafana.ini or port in use | Run # journalctl -u grafana-server -xe to see logs. Correct syntax, change port, restart. |
| Port 3000 already in use | Another app (maybe NodeJS app or Jenkins) | sudo lsof -i :3000 → stop or reassign the conflicting service. |
| Blank login page / dashboard not loading | Browser cache or reverse proxy misconfig | Clear cache, check Nginx proxy settings (proxy_pass should point to http://localhost:3000). |
| APT key errors (Ubuntu 22.04+) | apt-key deprecated | Use signed-by=/usr/share/keyrings/grafana.gpg method as Grafana docs suggest. |
| “Bad Gateway” via proxy | Missing header forwarding | In Nginx config, ensure: |
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;
“` |
| **Can’t access Grafana from LAN**
Most common reason Firewall blocking port
# ufw allow 3000/tcp
(or adjust firewalld).
10. Maintenance and Backup Tips
– Backup your dashboard database frequently:
– SQLite: `/var/lib/grafana/grafana.db`
– MySQL/PostgreSQL: use your normal DB backup methods
– Watch logs regularly, e.g.:
# journalctl -u grafana-server -f
-
Upgrade grafana safely:
# apt update && apt install grafana -y
(Always back up before upgrading!)
Conclusion
Grafana is a powerful, elegant way to visualize your system metrics, application logs, and alerts.
Installing it on Linux is straightforward — but knowing where it can fail and how to fix it is what separates a beginner from a seasoned sysadmin.
By following this guide, you not only get Grafana up and running, but also understand the moving parts behind the scenes — a perfect fit for any DIY server admin or DevOps engineer who loves keeping full control.




