Resources · Port reference · port 9090
Port 9090 (Prometheus and Cockpit): what it is and how to secure it
Port 9090 is Prometheus, which has no login by default, or the Cockpit server console. Keep both on localhost or behind a VPN.
Check command
sudo ss -tlnp | grep ':9090 '
Copied.
Port 9090 is usually Prometheus or Cockpit. Prometheus has no authentication unless you add it, and its UI lists every server it monitors. Cockpit is a full web console for the server. Neither should be open to the internet.
What port 9090 is for
- Prometheus serves its query UI and API on 9090.
- Cockpit, the web admin console shipped with RHEL, Rocky, Alma, Fedora and available on Ubuntu, also defaults to 9090.
Why an open 9090 is risky
Prometheus:
- anyone can query your metrics and see internal hostnames, IPs, service names and versions from the target labels, which is a map for an attacker;
- if
--web.enable-lifecycleis set, anyone can shut Prometheus down or reload it; - if
--web.enable-admin-apiis set, anyone can delete data.
Cockpit: it logs in with system accounts and can open a terminal, so a public Cockpit is a password-guessing target with root at the end.
Check yours
sudo ss -tlnp | grep ':9090 '
systemctl is-active cockpit.socket
Fix it
Prometheus: bind it to loopback:
prometheus --web.listen-address=127.0.0.1:9090 ...
In Docker, publish 127.0.0.1:9090:9090. Grafana on the same host can still read it. If something remote must reach it, add basic auth and TLS with a web config file (--web.config.file), and restrict the source IPs.
Cockpit: if you do not use it, turn it off:
sudo systemctl disable --now cockpit.socket
If you do, keep it off the public interface (close 9090 in the firewall and the provider's firewall) and reach it through an SSH tunnel:
ssh -L 9090:127.0.0.1:9090 you@your-server
Monitoring several servers
When Prometheus scrapes exporters on other machines, those exporters have to accept connections from the Prometheus server, but from nobody else. Two common ways to do that:
- run the scrape traffic over a private network or a WireGuard tunnel, and bind each exporter to that private address;
- allow the exporter port in each server's firewall from the Prometheus server's IP only, for example
sudo ufw allow from 10.0.0.5 to any port 9100 proto tcp.
Grafana then reads from Prometheus on localhost, and only Grafana, behind HTTPS and a login, faces your team.
Common mistakes
- Exposing exporters too. node_exporter on 9100 has the same problem: no login, lots of detail.
- Leaving lifecycle or admin API flags on in production.
FAQ
Does Prometheus have a password? Not by default. Since version 2.24 it supports basic auth and TLS through a web config file.
How do I get warned? PortGate's Server Guard alerts when 9090, or any new port, starts answering on a public address.