Is it possible to change Kodi http port via command line?

My TV is broken and I cannot read the top 25% of the screen so I cannot use the on-screen menus (Settings->Services->Webserver)
I need to change Kodi default port for http (80) to install lighttpd running on port 80.
Is there a config file I can tweak and a command to kill/restart Kodi on the new port ?

BTW I see that Kodi opens quite a number of ports other than http, what are they used for ?

tcp 0 0 *:1287 : LISTEN 362/kodi.bin
tcp 0 0 :http : LISTEN 362/kodi.bin
tcp 0 0 :1302 : LISTEN 362/kodi.bin
tcp 0 0 :1464 : LISTEN 362/kodi.bin
tcp 0 0 :36666 : LISTEN 362/kodi.bin
tcp6 0 0 [::]:9090 [::]:
LISTEN 362/kodi.bin
tcp6 0 0 [::]:http [::]:
LISTEN 362/kodi.bin
tcp6 0 0 [::]:36666 [::]:
LISTEN 362/kodi.bin
tcp6 0 0 [::]:36667 [::]:
LISTEN 362/kodi.bin
udp 0 0 *:9777 : 362/kodi.bin
udp 0 0 *:12352 : 362/kodi.bin
udp 0 0 *:1900 : 362/kodi.bin

Edit .kodi/userdata/guisettings.xml and search for section and look for <webserverport>8080</webserverport>

Well haven’t found all the details but it is things like UPNP, DLNA, Remote Control, Airplay…
http://kodi.wiki/view/Settings/Services

1 Like

Opps seems it does not work … changed 80 to 8080, restarted Kodi and even rebooted but the http server is still on port 80 (and I checked with the browser it’s Kodi :slight_smile: )

EDIT: checked … that value gets rewritten in the guisettings.xml file to the original port 80 every times Kodi is restarted or the Vero/OSMC rebooted.

So there must be some other config file overriding ?!?

Thanks again.

1 Like

Any manual change to guisettings.xml must be done when Kodi is not running. Kodi writes out guisettings.xml on exit this overwrites the change you made while it was running.

2 Likes

You must first exit Kodi with sudo service mediacenter stop

1 Like

Seems you suggestions are not enough (or I’m missing something obvious):smile:

osmc@osmc:~$ sudo service mediacenter stop
osmc@osmc:~$ sudo netstat -tulp | grep kodi
osmc@osmc:~$ vi .kodi/userdata/guisettings.xml
osmc@osmc:~$ grep webserver .kodi/userdata/guisettings.xml
        <webserver default="true">true</webserver>
        <webserverpassword default="true"></webserverpassword>
        <webserverport default="true">81</webserverport>
        <webserverusername default="true"></webserverusername>
osmc@osmc:~$ sudo service mediacenter start
osmc@osmc:~$ grep webserver .kodi/userdata/guisettings.xml
        <webserver default="true">true</webserver>
        <webserverpassword default="true"></webserverpassword>
        <webserverport default="true">80</webserverport>
        <webserverusername default="true"></webserverusername>
1 Like

The command is
sudo systemctl stop mediacenter

1 Like

You have to delete the default=“true” from the webserver port e.g. <webserverport>8080</webserverport>

1 Like

Thank you a LOT deleting default=true was the “trick”.

Both ways of stopping and starting the service seem to work. Differences ?

Well, in systemd, my way would have been more technically proper, but at the moment I was responding, I was away from my pi to test @fzinken’s command for function. :wink: Glad you got it sorted.

1 Like

Can you then please mark the thread as solved

Would love to but cannot find a button to do so. Should I just edit the title and place a [SOLVED] tag prefixing it ?
Thanks !

I just did it for you, basically click on the three dot’s (hover will show “show more”) and there click on the tick. This will do all for you

2 Likes

I changed the port and it worked after reboot. No need for anything else.