# /dev/ttyUSB0 No such port - AGAIN

**URL:** <https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021>\
**Category:** Installation\
**Tags:** docker, mysensors\
**Created:** [November 7, 2019, 5:23am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021 "2019-11-07T05:23:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 5:23am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/1 "2019-11-07T05:23:52Z")

</div>

I’ve read probably 20 threads about this problem here in the forum and on the internet but still I can’t get it working…  
I use the binding MySensors. The instillation went well and I could add the Port Settings in the PaperUI.

However I get this error:

> ```
> 06:13:46.071 [DEBUG] [ocol.serial.MySensorsSerialConnection] - Connecting to /dev/ttyUSB0 [baudRate:115200]
> 06:13:46.072 [ERROR] [ocol.serial.MySensorsSerialConnection] - No such port: /dev/ttyUSB0
> 
> ```
> 
> gnu.io.NoSuchPortException: null  
> at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:273) ~[260:com.neuronrobotics.nrjavaserial:3.15.0.OH2]  
> at org.openhab.binding.mysensors.internal.protocol.serial.MySensorsSerialConnection.establishConnection(MySensorsSerialConnection.java:51) [275:org.openhab.binding.mysensors:2.4.0.201812040738]  
> at org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection.connect(MySensorsAbstractConnection.java:148) [275:org.openhab.binding.mysensors:2.4.0.201812040738]  
> at org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection.run(MySensorsAbstractConnection.java:127) [275:org.openhab.binding.mysensors:2.4.0.201812040738]  
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]  
> at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]  
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]  
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]  
> at java.lang.Thread.run(Thread.java:748) [?:?]

OpenHab is running in a docker container with those additional arguments:

> EXTRA\_JAVA\_OPTS = -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0

devices:

> /dev/USB0:/dev/USB0

So /dev/ttyUSB0 is for sure the right port.  
I can read the data with

> cat /dev/ttyUSB0

On the linux server and when I go to the docker with:

> docker exec -it openhab /bin/bash

I can also read the serial port by using the same command:

> cat /dev/ttyUSB0

I also added:

> adduser openhab dialout  
> adduser openhab tty

but somehow each time I restart the docker I need to add the

> adduser openhab tty

command again…

when I enter this command:

> docker lgs openhab

I get a long list with this error:

> java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver

What else can I do what might be the problem?

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [November 7, 2019, 5:34am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/2 "2019-11-07T05:34:33Z")

</div>

I think I once read that when using Docker the ports may not be immediately available and sleeping a couple of seconds before starting OH may help by adding a startup script:

> <https://github.com/openhab/openhab-docker/blob/main/README.md#executing-shell-scripts-before-openhab-is-started>

Does it also work if you restart the binding again using the Console? If so, the binding may be missing serial port reconnection logic which would make it a lot more stable.

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 5:38am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/3 "2019-11-07T05:38:56Z")

</div>

So I restarted the binding but no success:

> 06:37:25.990 [DEBUG] [org.openhab.binding.mysensors] - BundleEvent STOPPED - org.openhab.binding.mysensors  
> 06:37:25.992 [DEBUG] [org.openhab.binding.mysensors] - BundleEvent STARTING - org.openhab.binding.mysensors  
> 06:37:25.993 [DEBUG] [org.openhab.binding.mysensors] - BundleEvent STARTED - org.openhab.binding.mysensors  
> 06:37:25.999 [DEBUG] [org.openhab.binding.mysensors] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=507, service.bundleid=275, service.scope=bundle, component.name=org.openhab.binding.mysensors.factory.MySensorsHandlerFactory, component.id=339} - org.openhab.binding.mysensors  
> 06:37:26.054 [DEBUG] [ensors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge  
> 06:37:26.054 [INFO] [ome.event.ThingStatusInfoChangedEvent] - ‘mysensors:bridge-ser:616dc2bb’ changed from UNINITIALIZED (HANDLER\_MISSING\_ERROR) to INITIALIZING  
> 06:37:26.055 [DEBUG] [sensors.factory.MySensorsCacheFactory] - Cache file: given\_ids.cached exist.  
> 06:37:26.056 [DEBUG] [sensors.factory.MySensorsCacheFactory] - Cache (given\_ids) content:   
> 06:37:26.057 [DEBUG] [ocol.serial.MySensorsSerialConnection] - Enabling connection watchdog  
> 06:37:26.066 [DEBUG] [ocol.serial.MySensorsSerialConnection] - Connecting to /dev/ttyUSB0 [baudRate:115200]  
> 06:37:26.066 [DEBUG] [org.openhab.binding.mysensors] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=508, service.bundleid=275, service.scope=singleton} - org.openhab.binding.mysensors  
> 06:37:26.066 [ERROR] [ocol.serial.MySensorsSerialConnection] - No such port: /dev/ttyUSB0

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [November 7, 2019, 5:42am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/4 "2019-11-07T05:42:49Z")

</div>

If it never works it may also be a permissions problem or Docker configuration problem. On some Synology NASes you also need to load extra kernel modules for serials comms to work.

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 5:44am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/5 "2019-11-07T05:44:48Z")

</div>

It has never worked yet (just trying now for 2 days)  
Its a normal server no NAS etc with an Intel Xeon processor running in VM.  
But why can I read data (with cat) in the docker itself but openhab can’t?

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 5:58am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/6 "2019-11-07T05:58:47Z")

</div>

the user 9001 that is used for openhab according to the docker has those writes on the mail system:

> id openhab  
> uid=9001(openhab) gid=9001(openhab) groups=9001(openhab),5(tty),20(dialout)

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [November 7, 2019, 6:17am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/7 "2019-11-07T06:17:41Z")

</div>

How did you pass the EXTRA\_JAVA\_OPTS to the container?

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 6:19am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/8 "2019-11-07T06:19:23Z")

</div>

over the ENV option:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/4/7/47262db0d3a1c697958e95ad8266b9659ce8ccad.png)

---

<div class="post-metadata">

**Author:** ![wborn](https://community.openhab.org/user_avatar/community.openhab.org/wborn/32/55946_2.png) [@wborn](https://community.openhab.org/u/wborn)\
**Post date:** [November 7, 2019, 6:39am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/9 "2019-11-07T06:39:50Z")

</div>

It looks good to me! Maybe @TimO can help?

---

<div class="post-metadata">

**Author:** ![Bruce\_Osborne](https://community.openhab.org/user_avatar/community.openhab.org/bruce_osborne/32/38531_2.png) [@Bruce\_Osborne](https://community.openhab.org/u/Bruce_Osborne)\
**Post date:** [November 7, 2019, 9:56am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/10 "2019-11-07T09:56:21Z")

</div>

Have you added that port to the EXTRA\_JAVA\_OPTS in the start.sh file? I recently went through some port troubleshooting and found this in the OH documentation.

> **[Serial - Bindings](https://v2.openhab.org/addons/bindings/serial1/)**
>
> The Serial binding allows openHAB to communicate over serial ports attached to the openHAB server.

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 10:10am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/11 "2019-11-07T10:10:39Z")

</div>

Tried to do taht but failed because of the permission.  
I made a start.sh file in the conf folder:

> -rwxrwxrwx+ 1 openhab openhab 122 Nov 7 11:04 start.sh

then I pointed the start command to this folder and script:

> `gosu openhab tini -s ./conf/start.sh`

But I get:

> - exec gosu openhab tini -s ./conf/start.sh  
> [FATAL tini (22)] exec ./conf/start.sh failed: Permission denied

What kind of permission does the start.sh need

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 10:32am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/12 "2019-11-07T10:32:18Z")

</div>

even when I directly copy the `start.sh` inside the container to the `conf` folder I get the same permission error

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 10:51am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/13 "2019-11-07T10:51:31Z")

</div>

so I made a new docker file to test if it would work. However I’m not sure how to add the Paramter to the start.sh file. My Start.sh file now looks like this:

> #!/bin/sh
> 
> echo Launching the openHAB runtime…
> 
> EXTRA\_JAVA\_OPTS=“-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0”
> 
> DIRNAME=`dirname "$0"`  
> exec “${DIRNAME}/runtime/bin/karaf” “${@}”

---

<div class="post-metadata">

**Author:** ![Bruce\_Osborne](https://community.openhab.org/user_avatar/community.openhab.org/bruce_osborne/32/38531_2.png) [@Bruce\_Osborne](https://community.openhab.org/u/Bruce_Osborne)\
**Post date:** [November 7, 2019, 11:09am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/14 "2019-11-07T11:09:46Z")

</div>

I have also had success adding the OPTS string to `/etc/default/openhab2` configuration file to resolve my test issue That file needs to be edited as `root`

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 11:41am UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/15 "2019-11-07T11:41:38Z")

</div>

> [@Bruce\_Osborne](#):
>
> /etc/default/openhab2

hmm cant find this “file”, can you show me a console output

---

<div class="post-metadata">

**Author:** ![CrazyIvan359](https://community.openhab.org/user_avatar/community.openhab.org/crazyivan359/32/83351_2.png) [@CrazyIvan359](https://community.openhab.org/u/CrazyIvan359)\
**Post date:** [November 7, 2019, 12:04pm UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/16 "2019-11-07T12:04:05Z")

</div>

Have you tried reading the port as the openhab user inside the container?

```auto
su - openhab -c 'cat /dev/ttyUSB0'

```

Just a thought, it may reveal an error, or confirm that the permissions are not the issue.

---

<div class="post-metadata">

**Author:** ![Bruce\_Osborne](https://community.openhab.org/user_avatar/community.openhab.org/bruce_osborne/32/38531_2.png) [@Bruce\_Osborne](https://community.openhab.org/u/Bruce_Osborne)\
**Post date:** [November 7, 2019, 12:33pm UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/17 "2019-11-07T12:33:37Z")

</div>

From what I understand from a GitHub issue I opened for a different binding, there are different ways the binding uses to access the serial port device.

See here.

> <https://github.com/openhab/openhab-core/issues/1176#issuecomment-549050579>
>
> Possible bug related to https://github.com/openhab/openhab-core/pull/866
> 
> Star…ting with 2.5M2, although the serial ports are discovered, they cannot be used reliably. We see this particularly with the Zigbee binding using an Ember coordinator. It can be reliably reproduced by restarting the Zigbee addon bundles. I have not found any debug logging to provide more error details. Here is what we see in the logs.
> 
> \> 19:53:06.321 \[ERROR\] \[nding.zigbee.handler.ZigBeeSerialPort\] - Serial Error: Port /dev/ttyUSB1 does not exist.
> 19:53:06.325 \[ERROR\] \[.zigbee.dongle.ember.ZigBeeDongleEzsp\] - Unable to open Ember serial port
> 
> A restart of OpenHAB usually gives proper connectivity.
> 
> I currently have a test system & USB stick I can use to help troubleshoot. If this is expected behavior, then the openHABian Linux documentation needs to be updated to reference the configuration file change needed.

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 12:42pm UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/18 "2019-11-07T12:42:15Z")

</div>

this works wihtout a problem:

> root@openhab:/openhab# su - openhab -c ‘cat /dev/ttyUSB0’  
> 0;255;3;0;9;10027 TSM:FAIL:RE-INIT  
> 0;255;3;0;9;10030 TSM:INIT  
> 0;0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA—,REL=255,VER=2.3.1  
> 0;255;3;0;9;5 TSM:INIT  
> 0;255;3;0;9;7 TSF:WUR:MS=0  
> 0;255;3;0;9;14 !TSM:INIT:TSP FAIL  
> 0;255;3;0;9;17 TSM:FAIL:CNT=1  
> 0;255;3;0;9;20 TSM:FAIL:DIS  
> 0;255;3;0;9;22 TSF:TDI:TSL

---

<div class="post-metadata">

**Author:** ![CrazyIvan359](https://community.openhab.org/user_avatar/community.openhab.org/crazyivan359/32/83351_2.png) [@CrazyIvan359](https://community.openhab.org/u/CrazyIvan359)\
**Post date:** [November 7, 2019, 12:53pm UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/19 "2019-11-07T12:53:49Z")

</div>

Please post logs and code using code fences, it makes them easier to read. There are buttons above the edit box for a post to insert them for you.

> [@AndreasK](#):
>
> java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver

This is interesting, it sounds like you’re missing a driver possibly? Or you’ve specified the wrong thing in your Java extra options?

Also for the record I have yet to use any serial bindings, but I do run openhab in docker. I’m just coming at this with general diagnostic questions.

---

<div class="post-metadata">

**Author:** ![AndreasK](https://community.openhab.org/user_avatar/community.openhab.org/andreask/32/37316_2.png) [@AndreasK](https://community.openhab.org/u/AndreasK)\
**Post date:** [November 7, 2019, 12:58pm UTC](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021/20 "2019-11-07T12:58:30Z")

</div>

I need the serial interface for the MySensor Binding. The instruction I used is from here:

> **[Installation](https://github.com/tobof/openhab-addons/wiki/Installation)**
>
> The next-generation open Home Automation Bus (openHAB) - tobof/openhab-addons

> **[OpenHAB 2.5 MySensors Serial Gateway - How to install](https://forum.mysensors.org/topic/6694/openhab-2-5-mysensors-serial-gateway-how-to-install/1?lang=en-GB)**
>
> \[update 2018-03-03 for version 2.2\] \[update 2019-01-05 for version 2.4\] \[updates 2019-04 add esh-io-transport-mqtt (needed even for serial gateway) and stop ...

[Next page](https://community.openhab.org/t/dev-ttyusb0-no-such-port-again/85021.md?page=2)
