Changing port number on openHAB 2.0

since the demo-server is running on 9080 i am quite sure that changing the port worked (at least for oh2a2 release). Which OS are you running?

@teichsta I am running this on Windows 10 with JAVA 1.8.0_51 and openHAB runtime is v2.0.0, build 201508080141.

I can access openHAB only on port 8080

which doesn’t seem to be the recent version (see Frankly i didn’t try the Win version. Can anybody of the Win-Users confirm that this bat file isn’t working properly?

@teichsta Just downloaded the latest snapshot from cloudbees - openHAB runtimev2.0.0, build 201509021732. Still seeing the same behaviour. :frowning:

ports under 1024 are restricted ports, though I am not sure how Windows respects that. Have you tried running OpenHAB with elevated privs under windows (ie as administrator) ?

I’m the author of PR 332 which allows you to set the HTTP and HTTPS ports without needing to change the start.bat scripts.

You should just need to set an environment variable OPENHAB_HTTP_PORT to, say, 4711, to make OH2 run on a port different to the standard 8080.

Having said that, I have tested this change only on my Linux setup. Also, the comment with “ports under 1024” holds true on Windows as well. If you really need OH2 to run on port 80, you should configure a reverse proxy for that.

@xsnrg and @hakan Yes to the fact that ports under 1024 are restricted but I have successfully tested running openHAB on port 80 under version 1.7.0 and 1.7.1 by simply changing the start.bat (and start_debug.bat) files. The environment variable was not set in either case. Here is a break down of the use cases I have tried:

  1. Edit startup.bat to change ports - Works with 1.7.x and NOT with 2.0 (no elevated privileges needed)
  2. Add environment variable OPENHAB_HTTP_PORT and set it to 80 (no changes to startup scripts) - DOES NOT WORK FOR 1.7.x & 2.0
  3. Run as a service - same as 1.

This is true on windows 8.1 and WIndows 10 - both 64 bit versions.

I would guess the solution is very simple. As @teichsta claims, it works with and @mganapa says that start.bat does not work, I see an important difference in the files:

-Dorg.osgi.service.http.port=$HTTP_PORT \$HTTPS_PORT \


-Djetty.port=%HTTP_PORT% ^
-Djetty.port.ssl=%HTTPS_PORT% ^

I would assume this is a bug in the bat file. @mganapa, could you please try if replacing jetty.port by org.osgi.service.http.port solves the problem?


@Kai Thanks! That did the trick. Never thought of comparing the .sh file with the .bat. Works as expected now.

1 Like

Great, thanks for the feedback!
I have fixed this now:

Now that OH2 is using karaf, i think to change the port, you need to change it in

or can these still be set in


@Kai -Ah cool - i had not seen any of the documentation under here. It answers many many questions i had so thanks for linking to it!

1 Like

Yes, it is important to note that is the new “entry point” for openHAB 2 - the repo now only contains add-ons (as its new name suggests).

@kai I’m using the latest beta snapshot and have set the environment arguments but openhab2 is still starting on port 8080 instead of 80.
I’m using openhab2 on the rpi maybe it’s because of the rpi

Just tested it on my Mac and it works. I would expect the same behaviour on a RPi.
You might not be able to use any port below 1024 though as those are priviledged.

I’m running openhab as sudo so normally it should have root privileges.
I will try to change to an other port above 1024 to check if that works

ENV Variable OPENHAB_HTTP_PORT didnt work for me either. I used the XML file.

Okey than i’m going to try the xml way

I was looking for this info too. The 2.0 b3 obeys the port config in /etc/defaults/openhab2 file:


I had to change it, as the 8080 was already taken by another app, motion. Maybe this helps someone looking for info, and would end up into docs. Note, it must have “export” in it.