How do I change port 3000 on Raspberry Pi?

Hello, I have Grafana running well on a few Raspberry Pi units . I have been searching here and elsewhere to try and change one of them to port 4000 from the default 3000 and I am just not having success . each attempt still returns netstat -lptn showing just 3000 for tcp6 …Any help is much appreciated…I learn quickly but this one has got me…maybe I need to get out of the house for a bit ! ! Thanks in advance

Does the following help you identify what needs to be changed, and perhaps
what you haven’t changed on your system?

/etc/grafana# grep -r 3000 .
./grafana.ini:;http_port = 3000
./grafana.ini:;root_url = http://grafana.staged-by-discourse.com

Note that if you do change either of the above, make sure to remove the “;” at
the start of the line, otherwise it remains commented-out and has no effect…

I assume you have restarted Grafana after making any such change?

Antony.

My problem is more so that I do not know how to change those lines ! ! Sorry for my basic question…I need some direction on how to get to these in order to change. Yes , I am restarting Grafana each time. Thank you !

My problem is more so that I do not know how to change those lines ! !
Sorry for my basic question…I need some direction on how to get to
these in order to change.

As root (note the “#” command prompt):

cd /etc/grafana

vi grafana.ini

/3000

That should take you to the first line containing the number “3000”.

Press the “delete” key to remove the semicolon at the start of the line (which
signifies a comment, and means that the line does not change the Grafana
configuration).

The press the right arrow key until the cursor is on the “3” of “3000”.

Press “r” and then “4”. The value “3000” should change to “4000”.

I do not believe you need to change the second instance of 3000 for your
setup, so you can now save the edited file and restart Grafana:

Press “:”, “w” and “q”.

(If anything went wrong with the above instructions and you did not end up
with the line:

;http_port = 3000

changed to:

http_port = 4000

then instead of “:”, “w” and “q”, instead press “:”, “q” and “!” to quit
without saving, then have another go from the top of these instructions.)

Assuming you successfully edited the file and saved it, restart Grafana and
check whether it is now listening on port 4000.

Yes , I am restarting Grafana each time.
Thank you !

Okay, good (that you’re restarting after whatever you’re doing), and you’re
welcome.

Antony

I was in…and figured out the removal of the ; and changed to 4 for 4000…but something I did or the way I saved it erased the entire file. I have replaced it and wnat to try again. Can you please clarify how I SAVE the edited file ??

Thanks so much for this valuable help !!!

I was in…and figured out the removal of the ; and changed to 4 for
4000…but something I did or the way I saved it erased the entire
file. I have replaced it and wnat to try again. Can you please clarify
how I SAVE the edited file ??

Colon gets you into command mode

w tells it to write the file

q tells the editor to quit

Hence I wrote:

you can now save the edited file and restart Grafana:

Press “:”, “w” and “q”.

Note that I say “press” - I mean simply press those keys, do not press return
after them, do not separate them with space or comma, just press the three
keys colon, w and q.

Once you have got Grafana running on your Pi I recommend finding and working
through an online tutorial on basic Linux systems admin, because if you’re not
yet familiar with editing a text file, I think you’re going to have some
challenges running a Pi for any length of time. I’m not saying it’s difficult,
but then neither is riding a bicycle, but until you know what you’re doing,
it’s easy to hurt yourself.

Antony.

Apologies - one thing I did not make clear - press return after the q.

Antony.

That last detail was it ! I did misread it. True that I need to keep riding the bike…But help like this is great encouragement. This question pops up in searches a bit…Your answer was the most helpful. Thank You very much .