How to set the address openahb2 is listening on

Hi OH experts!

Is there a way to set the address (or hostname) to which OpenHab binds when it starts ?
This can be a very usefuld feature if you have a linux host having more IP addresses.

By the way I’m figure out how to run multiple OH2 instances on the same host.

Thanks to everybody.

If you use systemctl to start/stop, you can edit runtime/karaf/etc/openHAB-wrapper.conf. I’ve only changed the port numbers, but it looks like you can also set the IP/host name.


I tried to achieve the same thing, but it’s very hard to do. Using doesn’t have any effect on the listening address.

My solution for now looks like:

in /etc/default/openhab2 have those variables set:

EXTRA_JAVA_OPTS=" -Dorg.ops4j.pax.web.listening.addresses=::1"

Then in /usr/share/openhab2/runtime/karaf/etc/org.ops4j.pax.web.cfg comment the last line:

# Listening addresses. This should match host in the sslconnector/name attribute in jetty.xml
# org.ops4j.pax.web.listening.addresses =

This is needed, or the setting in /etc/defaults/openhab2 will have no effect.

So yes, it seems to be possible to change the listening address somehow, but it’s not very straight forward. I’d expect to setting to be enough (as works fine for https). If there is no way to also use but any other variable, it should be possible to override any configuration shipped with the package itself.

Should I open a bug report about this? For now, I can live with it, but it really complicates the setup. Once this works fine, I’d be happy to extend the reverse proxy setup documentation, because in such situations the internal server should not listen on global addresses but on localhost by default so the only way in from the outside world would be the proxy.

You can add the following two lines in the beginning of to make it listen on port 8081:

Thanks. That’s in fact well documented and works fine. What’s not as easy is to bind to a specific address.

Thanks for this! I just spent 30 minutes trying to figure out the same thing.

Created a PR to hopefully make this easier in the future.

1 Like