# Serial Port not open

**URL:** <https://discourse.nodered.org/t/serial-port-not-open/27885>\
**Category:** General\
**Created:** [6 June 2020 10:05 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885 "2020-06-06T10:05:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [6 June 2020 10:05 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/1 "2020-06-06T10:05:21Z")

</div>

Hi

I am getting the following error on a Raspberry pi 3 B+ when using the modbus node.

(node:747) UnhandledPromiseRejectionWarning: Error: Port is not open  
at fs.write (/home/pi/.node-red/node\_modules/@serialport/bindings/lib/unix-write.js:49:25)  
at FSReqWrap.wrapper [as oncomplete] (fs.js:509:5)  
(node:747) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)  
(node:747) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.  
It is strange because this happens on a new Pi Zero W and an older Pi 3B+ but works fine on an older Pi Zero. I have tried older versions of Raspbian and NR, but cannot identfy why the one Zero works

Any help or advice appreciated

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 12:22 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/2 "2020-06-06T12:22:19Z")

</div>

Does the user running Node-RED (pi I assume) belong to group "dialout" on the one that works and not the others? I doubt it though as I've just done a fresh install a week ago and my "pi" user is in the group without me adding it explicitly.

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [6 June 2020 12:30 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/3 "2020-06-06T12:30:50Z")

</div>

Thanks for the response, the pi user belongs to the "dialout" group on both

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 12:34 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/4 "2020-06-06T12:34:10Z")

</div>

This is a longshot but as `serialport` uses native bindings, maybe it needs to be rebuilt (perhaps Node version has changed or something). You could try rebuilding it with:

```auto
cd .node-red
npm rebuild

```

Then restart NR.

Edit: also observe for possible build errors for the module

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [6 June 2020 13:41 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/5 "2020-06-06T13:41:58Z")

</div>

Thanks, tried that but error remains. I have gone through all my Pi's and now found another A+ that also works fine. The only common issue I can find is both have a similar version of node (10.16 and 10.17)  
I have started again with a complete fresh install of Raspberry OS and NR but error the same

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 13:44 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/6 "2020-06-06T13:44:27Z")

</div>

Sorry, I'm out of ideas. Hopefully someone else will have more things to try.

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [6 June 2020 13:57 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/7 "2020-06-06T13:57:45Z")

</div>

Thanks for your help, I am just cheating for now, I have taken the SD card out of the A+ and put it into the 3 B+ (where I need it) and it works, so I am just going to make a image of this SD and use that until I can find a solution.

Thanks again 😉

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:00 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/8 "2020-06-06T14:00:12Z")

</div>

Interesting but a working solution!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:06 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/9 "2020-06-06T14:06:54Z")

</div>

> [@mtoko](#):
>
> I have started again with a complete fresh install of Raspberry OS and NR but error the same

Which version of nodejs have you got on the new install?

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:15 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/10 "2020-06-06T14:15:33Z")

</div>

I think I might have found the reason. It supports your findings:

> NodeJS has dropped prebuilt binaries for NodeJS 10 and above for 32bit linux. As a result it's too difficult to maintain support. However if you build nodejs and serialport yourself it will probably work.

> **[Supported Environments | Node SerialPort](https://serialport.io/docs/guide-platform-support)**
>
> Node-API (N-API)

This might have a lot of implications...

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [6 June 2020 14:17 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/11 "2020-06-06T14:17:57Z")

</div>

Maybe it got something to do they changed by default the port names on pi3&4

> **[Configuring The GPIO Serial Port On Raspbian Jessie and Stretch Including Pi...](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3-4/)**
>
> The Raspberry Pi GPIO serial port configuration has changed under Jessie / Stretch / Buster and also with the Raspberry PI 3 / 4. How to set it up.

Maybe you can try the chapter " Swapping the Serial Ports on Raspberry Pi 3 / 4" and see if it helps.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:19 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/12 "2020-06-06T14:19:02Z")

</div>

That would be a very good explanation. Have you checked this @mtoko?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:23 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/13 "2020-06-06T14:23:21Z")

</div>

Doesn't it compile it when you install the serial port anyway?

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:24 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/14 "2020-06-06T14:24:46Z")

</div>

This reminded of me the fact I just ran across the fact that an USB serial interface might bind to either `/dev/ttyAMA0` or `/dev/ttyACM0` depending on the situation. I just tried the search icon on the serial in node and it offered me both options (I have a CC2531 zigbee2mqtt stick attached).

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:26 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/15 "2020-06-06T14:26:27Z")

</div>

> [@Colin](#):
>
> Doesn't it compile it when you install the serial port anyway?

Yes but at least I've ran across a situation that I had to run `npm rebuild` after upgrading to a new major version of Node.

Edit: nevermind you were referring to the quote I sent. That is very true and it does compile fine on Node 14 on a 32-bit Raspbian for me.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [6 June 2020 14:30 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/16 "2020-06-06T14:30:29Z")

</div>

I think the documentation I linked was actually referring to 32bit i386 builds of Node.js.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:50 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/17 "2020-06-06T14:50:55Z")

</div>

I don't think it applies to Raspbian (except possibly the Zero, where I think 10 is the last available).

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [6 June 2020 15:06 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/18 "2020-06-06T15:06:42Z")

</div>

You are all genius! @edje11 the document that you liked to solved the problem. I changed the config.txt and assigned the GPIO14 and 15 the "main" UART to AMA0 and that fixed the problem

Thank you to everyone 😊

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 June 2020 15:31 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/19 "2020-06-06T15:31:55Z")

</div>

@colin luckily there are a good supply of unofficial builds still out there - [https://unofficial-builds.nodejs.org/download/release](https://unofficial-builds.nodejs.org/download/release)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 June 2020 15:32 UTC](https://discourse.nodered.org/t/serial-port-not-open/27885/20 "2020-06-20T15:32:00Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
