Eric Miller
Eric Miller

Reputation: 1407

Changing Grafana port

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.

Upvotes: 16

Views: 72314

Answers (11)

Rajaram Shelar
Rajaram Shelar

Reputation: 7877

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

Upvotes: 1

Ayansplatt
Ayansplatt

Reputation: 51

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

Upvotes: 0

govo
govo

Reputation: 500

You have to remove (;), like this:

http_port = 3900

Upvotes: -1

Jalansh
Jalansh

Reputation: 31

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

Upvotes: 3

user12817541
user12817541

Reputation: 11

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"

Upvotes: 0

sjMalik
sjMalik

Reputation: 398

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.

Upvotes: 25

Jason Kim
Jason Kim

Reputation: 19031

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

Upvotes: 22

Chau Giang
Chau Giang

Reputation: 1554

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.

Upvotes: 1

Tyler Dane
Tyler Dane

Reputation: 1069

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.

Upvotes: 2

Martin Magakian
Martin Magakian

Reputation: 3766

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/

Upvotes: 7

slashzero
slashzero

Reputation: 29

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.

Upvotes: -2

Related Questions