How to change Node Exporter port

Node Exporter by default uses port 9100. You may need to use another port for Node Exporter if port 9100 is already used by another program on your server. On an OVH VPS, noderig was running in port 9100 and Node Exporter failed to start. To fix the issue, i had to run Node Exporter on a different port.

To change the Node Exporter port, edit the file

/etc/systemd/system/node_exporter.service

Find line

ExecStart=/usr/local/bin/node_exporter

Replace it with

ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9101

In the above line, 9101 is the new Node Exporter port. You can change it to any other port as required.

Here is the complete code

root@ns568267:~# cat /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9101

[Install]
WantedBy=multi-user.target
root@ns568267:~# 

Reload systemd

systemctl daemon-reload

Restart node exporter

systemctl start node_exporter

You can verify node_exporter is running with the command

root@ns568267:~# netstat -lntp | grep node_
tcp6       0      0 :::9101                 :::*                    LISTEN      15630/node_exporter 
root@ns568267:~# 
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *