Karaf connection refused

I’m having issues connecting to Karaf console. Everything was working correctly in OH 2.1, but when I switched to snapshot I can no longer connect to Karaf console.

If I try ssh -p 8101 openhab@localhost, I get ssh: connect to host localhost port 8101: Connection refused.

I see from nmap localhost that port 8101 is not shown at all.

If I run /usr/share/openhab2/runtime/bin/client I get the following:
mkdir: cannot create directory â/usr/share/openhab2/userdata/tmpâ: No such file or directory
client: Ignoring predefined value for KARAF_HOME
client: KARAF_BASE is not valid: /usr/share/openhab2/userdata

Otherwise, OH is running just fine, status shows Active and all functionality running as normal.

Running Openhabian on an RPi3. Any suggestions on what to try next?

you could try:
shutdown OH2, clear /var/lib/openhab2/tmp/* and /var/lib/openhab2/cache/* and try again

…but… this: client: KARAF_BASE is not valid: /usr/share/openhab2/userdata is not a good message…
somehow the environment variables are not loaded correctly… I don’t know if this will be resolved by clearing tmp & cache… doubtful…
The correct KARAF_BASE = OPENHAB_USERDATA = /var/lib/openhab2/

netstat -atn |grep 8101 shows nothing?

I doubt deleting cache and tmp will do anything, but you’re welcome to give it a go.

Running the client manually won’t work on an automatic install unless you set OPENHAB_* environments, there’s a new version of /etc/default/openhab2 which shows you what these should be, export them first before trying the client file again to see any possible errors.


export OPENHAB_HOME=/usr/share/openhab2
export OPENHAB_CONF=/etc/openhab2
export OPENHAB_RUNTIME=/usr/share/openhab2/runtime
export OPENHAB_USERDATA=/var/lib/openhab2
export OPENHAB_LOGDIR=/var/log/openhab2

What comes up then? Otherwise, I’d suggest stopping openHAB, starting it again and then immediately:

tail -f /var/log/openhab2/openhab2

Anything related come up?

Same here with todays snapshot_
> root@pi3:/usr/share/openhab2# ./start_debug.sh
> Launching the openHAB runtime…
> Listening for transport dt_socket at address: 5005
> WARN: file:/usr/share/openhab2/userdata/etc/config.properties is not found, so not loaded
> null
> WARN: file:/usr/share/openhab2/userdata/etc/config.properties is not found, so not loaded
> Error occurred shutting down framework: java.lang.NumberFormatException: null
> java.lang.NumberFormatException: null
> at java.lang.Integer.parseInt(Integer.java:542)
> at java.lang.Integer.parseInt(Integer.java:615)
> at org.apache.karaf.main.ConfigProperties.(ConfigProperties.java:208)
> at org.apache.karaf.main.Main.updateInstancePidAfterShutdown(Main.java:226)
> at org.apache.karaf.main.Main.main(Main.java:191)

Again, you’ll need to set those environment variables.

export OPENHAB_HOME=/usr/share/openhab2
export OPENHAB_CONF=/etc/openhab2
export OPENHAB_RUNTIME=/usr/share/openhab2/runtime
export OPENHAB_USERDATA=/var/lib/openhab2
export OPENHAB_LOGDIR=/var/log/openhab2

Perhaps, we need a way of setting these env variables for the user in the linux packages.

Didn’t saw your post, 2min difference. :wink:
With the exports set it works again.

In my /etc/default/openhab the exports are comment out. It is a apt-get installation.

Ben - with the environment variables set, I can now get into Karaf using /client. Thanks!

Any ideas on how to get the service at an open port. There’s no port conflict (at one point I tried to change the port) and no firewall, just not offered at any available ports.

1 Like

I am running the latest OH 2.2 Snapshot #983 and I don’t see any of these problems… :frowning:

I also have all stuff commented out in /etc/default/openhab2

Ok, that’s odd. After connecting using ./client, I went back and tried SSH - both local and remote - and it’s working fine. Not sure what changed, but thanks everyone for their quick responses!!

@Dim, You will do if you just run.


But I’ll fix that soon, environment variables are being set for the service, but not for the user. To be clear /etc/default/openhab2 is not (and should not be) necessary and you should usually leave it as it is. It’s only there for custom modifications. This is also unrelated to connecting via SSH, which is the main problem in this thread.

@kjunker,I wouldn’t be able to say what happened for sure, the console may have got stuck and using the client may have prompted an unstick. Glad you have it working :wink:

1 Like

absolutely correct… i spoke too soon :slight_smile:


Will test this and merge hopefully at the end of the day.

1 Like

After installing the latest snapshot from this point of time, these environment variables will be available to you automatically when you next log on. This will allow you to quickly jump to a path of openHAB without remembering specifics, eg:

~                 >> echo $OPENHAB_CONF
~                 >> cd $OPENHAB_USERDATA
/var/lib/openhab2 >>

You won’t have to export anything before running ./start_debug.sh or /usr/share/openhab2/runtime/bin/client this way.

@ThomDietrich, just an FYI. this will also affect openHABian users as of 2.2.0~20170713021955-1. Might be fairly useful to people that SSH in.

1 Like

Nice! Thanks Ben.


just did an apt-get upgrade from 2.1 to the 2.2 stable release. I cannot reach the karaf console via direct ssh anymore. If I ssh on the pi and then go in the console there it is working. Before with 2.1 the karaf console worked fine.

Result for a ssh is “connection refused”. Is it still that problem? Can anyone tell?

The karaf shell settings updated so the file responsible for allowing remote access has gone back to default. (Which is to only allow localhost.)


You need to set sshHost. allows connections from anywhere but you should ideally change the default username and password if you do this.

1 Like

Thank you for your help. Nothing is working now and I could not even ssh to the console - was so frustrating… now I have the console to fix everything :smiley:

Thank you very much!

Just a noob on openhaal (installed it yesterday).

I have the same problem running openHAB on my synology

apparently karaf is only listening on the loopback interface?

ton@XSF:/volume1/public/openHAB/conf$ netstat -atn |grep 8101
tcp6 0 0 :::* LISTEN

Is that correct?

Where can the karaf shell cfg be found to make listen to


org.apache.karaf.shell:sshHost =

set it there (in runtime.cfg) and the setting will propagate to /var/lib/openhab2/etc/org.apache.karaf.shell.cfg
In principle (and as a rule…but there are exceptions): You shouldn’t directly modify files in /var/lib/openhab2/

First time posting anything on this forum. I too get “Connection refused” trying to run ssh -p 8101 openhab@localhost.
When I try to run /usr/share/openhab2/runtime/bin/client I get “Incompatible magic value 3271473854 in class file sun/security/jca/JCAUtil”
I’ve checked/changed sshhost = in …shell.cfg.
Any ideas of what to do ???