Changing port number on openHAB 2.0

Right, I have a test machine with Ubuntu 14 which will have the same service system. I should be able to test what’s going on in a couple of days and get back to you!

I did some more debuging and added this to both files.

echo "env: `export`" >> /tmp/oh_port.txt

from /etc/default/openhab2

export HOME='/root'
export LANG='de_BE.UTF-8'
export LOGNAME='root'
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:[..]'
export MAIL='/var/mail/root'
export PATH='/sbin:/usr/sbin:/bin:/usr/bin'
export PWD='/home/cwempe'
export SHELL='/bin/bash'
export SUDO_COMMAND='/etc/init.d/openhab2 stop'
export SUDO_GID='1002'
export SUDO_UID='1001'
export SUDO_USER='cwempe'
export TERM='xterm'
export USER='root'
export USERNAME='root'

from /usr/share/openhab2/runtime/bin/setenv

export EXTRA_JAVA_OPTS=''
export HOME='/root'
export KARAF_BASE='/var/lib/openhab2'
export KARAF_DATA='/var/lib/openhab2'
export KARAF_ETC='/var/lib/openhab2/etc'
export KARAF_HOME='/usr/share/openhab2/runtime'
export KARAF_SCRIPT='stop'
export LANG='de_BE.UTF-8'
export LOGNAME='root'
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:[..]'
export MAIL='/var/mail/root'
export OPENHAB_CONF='/etc/openhab2'
export OPENHAB_HOME='/usr/share/openhab2'
export OPENHAB_LOGDIR='/var/log/openhab2'
export OPENHAB_RUNTIME='/usr/share/openhab2/runtime'
export OPENHAB_USERDATA='/var/lib/openhab2'
export PATH='/sbin:/usr/sbin:/bin:/usr/bin'
export PWD='/home/cwempe'
export SHELL='/bin/bash'
export SUDO_COMMAND='/etc/init.d/openhab2 stop'
export SUDO_GID='1002'
export SUDO_UID='1001'
export SUDO_USER='cwempe'
export TERM='xterm'
export USER='openhab'
export USERNAME='root'

Does this help?

I couldn’t get this to work, and so ended up changing the ports on my other application…

I created an issue, because it seems to be a bug that should get fixed befor the final release.

EDIT: Created a new issue in the correct repository.

I am running OpenHub2 on windows 10 and was able to change the port to 80 by simply adding the following to the beggining of the start.bat file: set OPENHAB_HTTP_PORT=80

Running openHAB2 780 under Mac OS Sierra with the environment variable OPENHAB_HTTP_PORT set to 8888. env run in the terminal shows this value. SETENV does not recognize it and the change of the port only works when I change HTTP_PORT to 8888 in the script.

This worked on Ubuntu apt instal. I added OPENHAB_HTTP_PORT=8090 to that file and restarted.

I’m assuming that’s Ubuntu 16? Anything that doesn’t use sysVinit (most new versions of each distro) should work.

can confirm that this piece of documentation is still missing.
i am running the package on a synology and am trying to reconfigure the port in latest 2,1 0004 package i downloaded.

kindest regards

confirmed that the change needs to happen in the setenv file.
is there a fix allready for this ?
I had to edit following file to get this done

/volume1/@appstore/openHAB2/runtime/bin -->setenv

then changed the line from
if [ ! -z ${OPENHAB_HTTP_PORT} ]; then
HTTP_PORT=${OPENHAB_HTTP_PORT}
else
HTTP_PORT=8080

to

if [ ! -z ${OPENHAB_HTTP_PORT} ]; then
HTTP_PORT=${OPENHAB_HTTP_PORT}
else
HTTP_PORT=DESIRED PORT

Could we not just add the port to the /etc/default/openhab2 file?

same, after a lot of hair pulling I managed to change McMyadmin to jump ports and free up 8080 for openHAB, on with the show :smiley:

With the latest versions of the linux packages, this should now be the same across all systems. Editing the /etc/default/openhab2 file with the lines:

OPENHAB_HTTP_PORT=9090
OPENHAB_HTTPS_PORT=9091

will change the appropriate ports. Thanks @ralle for pushing this fix.

If it still doesn’t work as expected for some, let me know and I will work to resolve it.

2 Likes

Thank you! Although I switched my other applications and am running openHAB on default ports, so can’t test…

Hi,
I installed latest stable openHab2 on RPi3 and successfully changed ports in /etc/default/openhab2 as mentioned above.

The problem I have is that voice control with HABDroid only seems to work when I use port 8080.

Is this a bug or do I have to change ports in additional files?

UPDATE:
Everything works with latest HABDroid from git-repo on S5mini

1 Like

have the latest version, not working for me to change the port to 80

running on an RPi

Port 80 is a restricted port, you’ll need to openhab with root privileges to use it.

It might be more beneficial to run a reverse proxy instead.

thanks, it is working now, but still can’t pair Hue Emulator with Google Assistant

Afaik, it does not work with Google Assistant, only with Google Home, see Google Home Integration.

Can some tell me how to get a fresh openhabian install to use port 80 with ngnix reverse proxy ?

Which file(s) need changing ?