Use different port 8081 instead of 8080

I just migrated from openHAB2 to OH 3. In OH2 I easily could switch the port used by the internal webserver from 8080 to 8081 by editing /etc/default/openhab

This setting was not migrated and editing this file did not help. How can I change the port of openHAB displaying it’s web frontend?

There is an other user who wrote that it would not be possible to change the port using the file /etc/default/openhab.
For me it is working. I change the default port to port 8000 just for test purposes.
Running systemctl status openhab as shown below the status message shows that port 8080 would be used but this is not true as you can see by running netstat which shows that port 8000 is being used:

[19:06:56] root@myopenhabian:/opt/openhabian/functions# systemctl status openhab
● openhab.service - openHAB instance, reachable at http://myopenhabian:8080
   Loaded: loaded (/lib/systemd/system/openhab.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/openhab.service.d
           └─override.conf
   Active: active (running) since Wed 2021-01-06 17:31:41 CET; 4 days ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
 Main PID: 7213 (java)
    Tasks: 101 (limit: 2318)
   Memory: 358.9M
   CGroup: /system.slice/openhab.service
           └─7213 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openhab -Dopenhab.conf=/etc/openhab -Dopenhab.runtime=/usr/share/openhab/runtime -Dopenh

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
[19:07:12] root@myopenhabian:/opt/openhabian/functions# netstat -tulpn | grep java
tcp        0      0 127.0.0.1:8101          0.0.0.0:*               LISTEN      7213/java           
tcp        0      0 127.0.0.1:33933         0.0.0.0:*               LISTEN      7213/java           
tcp        0      0 0.0.0.0:5007            0.0.0.0:*               LISTEN      7213/java           
tcp        0      0 0.0.0.0:8443            0.0.0.0:*               LISTEN      7213/java           
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      7213/java           
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           7213/java

Also the ps command shows that the changed port is being used:

[19:10:53] root@myopenhabian:/opt/openhabian/functions# ps -ef |grep java |grep 8000
openhab    7213      1  0 Jan09 ?        00:05:24 /usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr/share/openhab -Dopenhab.conf=/etc/openhab -Dopenhab.runtime=/usr/share/openhab/runtime -Dopenhab.userdata=/var/lib/openhab -Dopenhab.logdir=/var/log/openhab -Dfelix.cm.dir=/var/lib/openhab/config -Djava.library.path=/var/lib/openhab/tmp/lib -Djetty.host=0.0.0.0 -Djetty.http.compliance=RFC2616 -Dnashorn.args=--no-deprecation-warning -Dorg.ops4j.pax.web.listening.addresses=0.0.0.0 -Dorg.osgi.service.http.port=8000 -Dorg.osgi.service.http.port.secure=8443 -Djava.awt.headless=true -XX:+UseG1GC --add-reads=java.xml=java.logging --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED --patch-module java.base=/usr/share/openhab/runtime/lib/endorsed/org.apache.karaf.specs.locator-4.2.7.jar --patch-module java.xml=/usr/share/openhab/runtime/lib/endorsed/org.apache.karaf.specs.java.xml-4.2.7.jar --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED -Dkaraf.instances=/var/lib/openhab/tmp/instances -Dkaraf.home=/usr/share/openhab/runtime -Dkaraf.base=/var/lib/openhab -Dkaraf.data=/var/lib/openhab -Dkaraf.etc=/var/lib/openhab/etc -Dkaraf.log=/var/log/openhab -Dkaraf.restart.jvm.supported=true -Djava.io.tmpdir=/var/lib/openhab/tmp -Djava.util.logging.config.file=/var/lib/openhab/etc/java.util.logging.properties -Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -classpath /usr/share/openhab/runtime/lib/boot/org.apache.karaf.diagnostic.boot-4.2.7.jar:/usr/share/openhab/runtime/lib/boot/org.apache.karaf.jaas.boot-4.2.7.jar:/usr/share/openhab/runtime/lib/boot/org.apache.karaf.main-4.2.7.jar:/usr/share/openhab/runtime/lib/boot/org.apache.karaf.specs.activator-4.2.7.jar:/usr/share/openhab/runtime/lib/boot/osgi.core-6.0.0.jar:/usr/share/openhab/runtime/lib/jdk9plus/istack-commons-runtime-3.0.8.jar:/usr/share/openhab/runtime/lib/jdk9plus/jakarta.xml.bind-api-2.3.2.jar:/usr/share/openhab/runtime/lib/jdk9plus/javax.activation-1.2.0.jar:/usr/share/openhab/runtime/lib/jdk9plus/javax.annotation-api-1.3.1.jar:/usr/share/openhab/runtime/lib/jdk9plus/jaxb-runtime-2.3.2.jar:/usr/share/openhab/runtime/lib/jdk9plus/txw2-2.3.2.jar org.apache.karaf.main.Main

Not the same here.
The service is running (though not explicitly saying “reachable at 8080”).
But netstat neither lists 8080 nor 8081:

[19:25:39] openhabian@openHABianPi:/etc/default$ sudo netstat -tulpn | grep java
tcp6 0 0 :::8443 :::* LISTEN 653/java
tcp6 0 0 127.0.0.1:8101 :::* LISTEN 653/java
tcp6 0 0 :::5007 :::* LISTEN 653/java
tcp6 0 0 127.0.0.1:38101 :::* LISTEN 653/java
udp6 0 0 :::5353 :::* 653/java

So I tried to access the Front-End by https:// and 8443. After accepting an insecure certificate it shows me the OH login screen. I do not know if I could also just work with that in future, but I’d rather find a solution to redirect the http-traffic in order to avoid conflicts with another application using 8080.

Maybe you overwrite in openhab-Konfigurations?
Search Files in /var/lib/openhab for Files with 8080 and if not marked out there, try to change there too.
Maybe a different configuration there overwrites the ubuntu configuration from /etc/default/openhab

Got it.

After the update there now are two files in /etc/default/
openhab2 and openhab

I did not realize the new one without the 2 before. Changed that, restarted service and now I can access the frontend on the desired port also without SSL.

All directories openhab3 are only openhab now (same in etc, var/lib, usr/share…)