Changing Grafana port
Asked Answered
S

11

16

I currently have InfluxDB feeding dashboards in Grafana. I will eventually be deploying this stack on a server.

However, the default port for Grafana is 80. I must change this port, but I don't know how. Can anyone help out?

Thanks.

Schoen answered 3/2, 2015 at 16:32 Comment(0)
C
24

Not only change in /etc/grafana/grafana.ini you have to change in /usr/share/grafana/conf/defaults.ini and /usr/share/grafana/conf/sample.ini files. Just search 3000 port(which is default port for grafana) in these three files and replace it with your preferred port.

Colet answered 15/6, 2018 at 6:22 Comment(3)
this works, but why do i need to change sample.ini too?Pianism
You don't. It is not used.Jospeh
this works. Can you explain more why I need to change later two places. Thanks. You save my day.Matta
P
21

Here's the easiest way I found.

docker run -d \
-p 2345:2345 \
--name grafana \
-e "GF_SERVER_HTTP_PORT=2345" \
grafana/grafana

See the documentation here.

https://grafana.com/docs/grafana/latest/installation/docker/#configuration

Phalanger answered 31/12, 2019 at 7:46 Comment(1)
Thanks for this, I was looking for so long to get this fixed. You made my day!Slivovitz
S
7

Since Grafana 2.0:

Grafana now ships with its own backend server

You can edit /etc/grafana/grafana.ini (usual location) and change the running port:

[server]
http_port=1234

Source: http://docs.grafana.org/installation/configuration/

Salian answered 24/4, 2015 at 15:56 Comment(1)
The Arch grafana package has it's ini located at /etc/grafana.ini.Kurtzman
U
3

If you are using Linux, you can change the default port by changing the port from /etc/grafana/grafana.ini. There is no separate custom.ini for Linux. For Windows, MacOS or any other platform, check the official documentation.

For opening grafana.ini, you would need sudo privileges. For changing the port please follow the steps below.

  1. Execute sudo gedit /etc/grafana/grafana.ini in a new Terminal window.
  2. Search for 3000 in the `.ini. file and you will find a line similar to the one shown below.
# The http port  to use
;http_port = 3000
  1. Remove the semicolon (;) and change the port to the port that you wish to run the grafana server on.
  2. Save the file and close gedit.
  3. You will need to restart the Grafana server for the changes to take place. Run sudo systemctl restart grafana-server.

The grafana server should be started on the port that you provided. Please note that you will have to write systemctl or service depending upon your init system. To determine your init system, run ps --no-headers -o comm 1.

Source

Unmarked answered 10/9, 2020 at 10:34 Comment(0)
L
2

For those using Docker:

Create a grafana.ini:

   [server]
   http_port = 1234

Update your Dockerfile:

    FROM grafana/grafana

    EXPOSE 1234

    ADD grafana.ini /etc/grafana

Build and run the container:

    docker build grafana

    docker run \
    -d \
    -p 1234:1234 \
    --name grafana \
    grafana/grafana

The EXPOSE is technically optional but is good practice for documentation.

Loiretcher answered 23/7, 2018 at 20:39 Comment(1)
Thanks. Works for meHolt
A
1

For Linux, I grab the setup file form here https://grafana.com/grafana/download?platform=linux

Then install it!

You only need to change this one /usr/share/grafana/conf/defaults.ini:

Replace:

http_port = 3000

With

http_port = YourPortYouWant

Then restart your app:

sudo service grafana-server stop
sudo service grafana-server start

To verify you should run:

sudo service grafana-server status

Then you can see the app lives in your desired port: enter image description here

Open up localhost:yourport to see the result.

I think the document from Grafana should be updated.

Ainslie answered 8/8, 2019 at 5:32 Comment(0)
R
1

On windows,

  1. Change port from 3000 to 3001 in "C:\Program Files\GrafanaLabs\grafana\conf\defaults.ini"
  2. Restart Grafana service from windows services
Rosemare answered 2/3, 2022 at 13:20 Comment(0)
T
0

For Windows 10 and Grafana v7.1.1, the following steps made the Grafana to be served in different port:

  1. Navigate to the Grafana "conf" folder location like "C:\Program Files\GrafanaLabs\grafana\conf"
  2. Copy the file "sample.ini" in the same location
  3. Rename the copied sample.ini to "custom.ini"
  4. Edit the "custom.ini" by opening in any editor.The editor must be running as Administrator.
  5. Uncomment the ";http_port = 3000" line by removing the semicolon(;). Note: Semicolon(;) is used to comment out lines in .ini files
  6. Change the port "3000" to whatever port is required. Make sure the new port should be admin rights. I changed to port "3001".
  7. Save the file.
  8. Restart the Windows machine.

The Grafana url is now hosted in "http://localhost:3001/?orgId=1"

Trilby answered 20/8, 2020 at 5:5 Comment(0)
L
0

I know its old thread but for me in Mac i had to make changes at 2 places.

I installed through Brew

/usr/local/etc/grafana/grafana.ini

/usr/local/Cellar/grafana/8.1.5/share/grafana/conf/defaults.ini

Loch answered 4/10, 2021 at 14:32 Comment(0)
S
-1

You have to remove (;), like this:

http_port = 3900

Slack answered 11/2, 2021 at 18:14 Comment(0)
S
-2

Grafana just runs behind a standard web server, like apache. If you are using apache, just update your virtual hosts file to use whatever port you want, and restart apache. Grafana will then be on the new port.

Supernatural answered 21/3, 2015 at 5:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.