Fixing a HG port change via SSH

Occasionally I’ve experienced HG changing its port on a service restart or reboot.
Since I run HG on a RPI in a headless configuration(no desktop, keyboard, or mouse)
Doing things in HG was only possible with the web UI if HG changed this it was a bit of a hassle trying to find the new port # and then login to HG and switch back.
Not a big deal if this was a local Machine a remote machine was impossible.
I then found a text based browser that runs in a terminal window (actually there are a few)
But will they run via SSH?
I suspect they all will but I know links will.
to install this type sudo apt-get install links
then to open a web page type links http://sitename

since this is running on the same device as HG typing it should get around the port forwarding though I’ve not been able to fully test this yet. typing in links http://.0.0.0.0:80 will open HG if it was on port 80.
since my reasoning for this was to fix a port change in HG I need to see what it changed to or just keep trying ports. using **sudo netstat -tulpn | grep LISTEN** I can find out ports in use so that speeds things up.

I just tested this with my off grid place and all works! :sunglasses:
Thinking this over :thinking: a simpler route may have been to just port forward a range of ports for HG in my router. However the fewer ports open the better.