Port number problems after re-install

I apt-get installed OH2 on my rPi 3 a few weeks ago. After play around for a while with setup (which still vexes me), I decided to wipe and start from scratch. I followed the instructions here Reset Config and Databases to remove my configs, but that didn’t seem to do what I expected (the web UI was just broken after that). No problemo - I just ran apt-get remove openhab2, which worked easily, then I rebooted, and ran apt-get install openhab2-addons (I wanted both core and addon packages, so this was shorthand, of course). So far so good.

I had previously modified /etc/default/openhab2 so that it would listen on port 8080, which worked for the initial install. After re-install I can’t seem to connect at all and I see OH2 is now, for some reason, on port 8181, despite the config still telling it listen on 8080.

I don’t mind it being on 8181, but I suspect that’s a symptom of some larger problem because I can’t seem to connect, even on 8181 (it has been running for well over an hour, so this isn’t the “wait 15 min” thing… also, it only took about 3 minutes from install to usable last time around):

Problem accessing /. Reason:

    Not Found
Powered by Jetty:// 9.3.22.v20171030

Here’s proof it is running, it is configured to 8080, but it somehow started on 8181. I don’t see any errors or useful details in /var/log/openhab2/openhab.log or events.log, only the usual stuff after a successful install.

root@raspberrypi:/var/log/openhab2# /bin/systemctl | grep -C 2 open; grep -C 2 port /etc/default/openhab2; netstat -lptn
networking.service                                                                                      loaded active exited    LSB: Raise network interfaces.
ntp.service                                                                                             loaded active running   LSB: Start NTP daemon
openhab2.service                                                                                        loaded active running   openHAB 2 - empowering the smart home
packagekit.service                                                                                      loaded active running   PackageKit Daemon
polkitd.service                                                                                         loaded active running   Authenticate and Authorize Users to Run Privileged Tasks
## The ports openHAB will bind its HTTP/HTTPS web server to.

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0  *               LISTEN      632/vncserver-x11-c
tcp        0      0    *               LISTEN      757/sshd        
tcp        0      0 *               LISTEN      8070/cupsd      
tcp6       0      0 :::5900                 :::*                    LISTEN      632/vncserver-x11-c
tcp6       0      0 :::5007                 :::*                    LISTEN      24959/java      
tcp6       0      0 :::8181                 :::*                    LISTEN      24959/java      
tcp6       0      0 :::22                   :::*                    LISTEN      757/sshd        
tcp6       0      0 ::1:631                 :::*                    LISTEN      8070/cupsd      
tcp6       0      0         :::*                    LISTEN      24959/java      
tcp6       0      0          :::*                    LISTEN      24959/java      

Any help would be appreciated.

Hi @qwenxuep,

Try using the command:

openhab-cli info
sudo systemctl status openhab2 

Could you post the results of each?

Sure. Since the output shows 8080 I also tried to telnet to myself on that port (running that from the rPi, which is 192:168.1.3) and that fails, as you see:

root@raspberrypi:/var/log/openhab2# openhab-cli info
Version:     2.2.0 (Build)

User:        openhab (Active Process 24959)
User Groups: openhab dialout

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | openhab:openhab
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab


root@raspberrypi:/var/log/openhab2# sudo systemctl status openhab2
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled)
   Active: active (running) since Sat 2018-05-19 16:27:21 PDT; 22min ago
     Docs: http://docs.openhab.org
 Main PID: 24959 (java)
   CGroup: /system.slice/openhab2.service
           └─24959 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/v...

May 19 16:28:38 raspberrypi karaf[24959]: at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1361) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:888) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1248) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$1(FeaturesServiceImpl.java:1147) ~[?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
May 19 16:28:38 raspberrypi karaf[24959]: at java.lang.Thread.run(Thread.java:748) [?:?]
root@raspberrypi:/var/log/openhab2# telnet localhost 8080
Trying ::1...
telnet: Unable to connect to remote host: Connection refused

Maybe this is meaningful - I found port 8181 in a config file that sits in the userdata directory… ??

root@raspberrypi:/var/lib/openhab2/etc# grep 8181 *
grep: scripts: Is a directory

I wouldn’t worry about that. The fact that the CLI reports the URL to be is a good indicator that it will use the correct port.

The errors that follow in the systemctl status command hint that openHAB is in a weird state. Did you manually delete folders and files in /var/lib/openhab2?

Those errors can be further investigated using the command:

sudo journalctl -u openhab2 -b

Perhaps this indicates anything useful? Feel free to post here if you’re unsure. Otherwise, the easiest thing to do to revert everything to defaults and remove everything including configuration is to run:

sudo apt purge openhab2
sudo apt install openhab2

since using apt remove doesn’t get rid of configuration files for a package and will keep your settings for the next install.

Yes, that’s exactly what I did (my first post links to the thread that instructed to do that if you want to revert to defaults)!

I thought apt remove got me a truly fresh start. I’ll try purge instead, gracias (from a redhat/yum user who isn’t very good with apt)!

No worries! :slight_smile: yum and apt work fairly differently so it can be a pain to go straight from one to the other. I think a yum remove does get rid of everything.

@rlkoshak, would you be able to edit that post? Unfortunately, deleting the userdata folder will break openhab, so it needs to be fully replaced. Obviously, manual users can just copy the distro folder from the zip across. But for apt users, deleting a file or folder is regarded as a valid configuration, so it will not attempt to replace the file unless you specify the command:

sudo apt -o Dpkg::Options::="--force-confmiss" install --reinstall openhab2
1 Like

I got my Docker and my apt mixed up. entrypoint.sh in Docker users an empty userdata to signify that this is a new install and to populate the folder. I’ll update that post with this command.

1 Like