# Error: connect ENETUNREACH on node-red-node-email

**URL:** <https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971>\
**Category:** General\
**Created:** [13 October 2022 09:34 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971 "2022-10-13T09:34:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 09:34 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/1 "2022-10-13T09:34:39Z")

</div>

Hi,

I'm getting a "send failed" and the following error when trying to send an email with the email node (node-red-node-email).

Error: connect ENETUNREACH 2a00:1450:400c:c00::6c:465 - Local (:::0)  
at internalConnect (node:net:1010:16)  
at defaultTriggerAsyncIdScope (node:internal/async\_hooks:464:18)  
at node:net:1103:9  
at processTicksAndRejections (node:internal/process/task\_queues:78:11)

The mail node was working fine until I did a restart of the Raspberry Pi, no changes had been made.  
I had this once before and got it working again after:

1. deleting all 5 email node,
2. uninstalling the node-red-node-email completely
3. restarting the Raspberry
4. installing the node-red-node-email
5. adding and configuring all 5 email nodes

Environment:  
Raspberry Pi 4 running Raspberry Pi OS Lite 32 bit  
Node Red v3.0.2  
npm v8.15.0  
node.js v16.17.1  
node-red-node-email v1.17.0

Any ideas on how to fix this permanently?

---

<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:** [13 October 2022 09:47 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/2 "2022-10-13T09:47:33Z")

</div>

It appears to be trying to use IPv6 to connect to the server. What have put for the email server address in the email node? Also what do you see if you run  
`ping server_name`  
where server\_name is whatever you have put as the server in the email node.

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 10:06 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/3 "2022-10-13T10:06:10Z")

</div>

I'm sending via gmail.  
Server: [smtp.gmail.com](http://smtp.gmail.com)  
Port: 465  
Use secure connection: ticked

PING [smtp.gmail.com](http://smtp.gmail.com) (108.177.15.109): 56 data bytes  
64 bytes from 108.177.15.109: icmp\_seq=0 ttl=101 time=32.528 ms  
64 bytes from 108.177.15.109: icmp\_seq=1 ttl=101 time=32.377 ms  
64 bytes from 108.177.15.109: icmp\_seq=2 ttl=101 time=33.216 ms

---

<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:** [13 October 2022 10:41 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/4 "2022-10-13T10:41:35Z")

</div>

How did you install node red? Is it a docker install for example?  
Are you absolutely certain this is coming from the email node?

What do these commands give?  
`ip addr`  
`dig smtp.gmail.com`  
`ping6 smtp.gmail.com`

---

<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:** [13 October 2022 12:15 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/5 "2022-10-13T12:15:46Z")

</div>

We do seem to have suddenly started seeing this a bit - eg see this thread - [Sending email : "Error can not use ipv4 addresses with current network"](https://discourse.nodered.org/t/sending-email-error-can-not-use-ipv4-addresses-with-current-network/67598/) - no-one has totally pinned it down yet.

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 12:42 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/6 "2022-10-13T12:42:55Z")

</div>

The Error comes from the email node. But the root cause is probably something else, potentially IPv6 related. I'm quite new to this so no experience in debugging at this level.

I used this script to install Node Red

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

```

from [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi)

In the outputs below I've removed (what I believe can be ) identifying data, change are within

**ip addr**  
1: lo: \<LOOPBACK,UP,LOWER\_UP\> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000  
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
inet 127.0.0.1/8 scope host lo  
valid\_lft forever preferred\_lft forever  
inet6 ::1/128 scope host  
valid\_lft forever preferred\_lft forever  
2: eth0: \<NO-CARRIER,BROADCAST,MULTICAST,UP\> mtu 1500 qdisc mq state DOWN group default qlen 1000  
link/ether [xx:xx:xx:xx:xx:7c] brd ff:ff:ff:ff:ff:ff  
3: wlan0: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc pfifo\_fast state UP group default qlen 1000  
link/ether [xx:xx:xx:xx:xx:7d] brd ff:ff:ff:ff:ff:ff  
inet 192.168.1.115/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0  
valid\_lft 65492sec preferred\_lft 54692sec  
inet6 [fe80::xxxx:xxxx:xxxx:3759]/64 scope link  
valid\_lft forever preferred\_lft forever  
4: ztugayhmgh: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 2800 qdisc pfifo\_fast state UNKNOWN group default qlen 1000  
link/ether [xx:xx:xx:xx:xx:xx] brd ff:ff:ff:ff:ff:ff  
inet 172.22.185.220/16 brd 172.22.255.255 scope global ztugayhmgh  
valid\_lft forever preferred\_lft forever  
inet6 [fe80::xxxx:xxxx:xxxx:4f29]/64 scope link  
valid\_lft forever preferred\_lft forever

**dig [smtp.gmail.com](http://smtp.gmail.com)**  
; \<\<\>\> DiG 9.16.33-Raspbian \<\<\>\> [smtp.gmail.com](http://smtp.gmail.com)  
;; global options: +cmd  
;; Got answer:  
;; -\>\>HEADER\<\<- opcode: QUERY, status: NOERROR, id: 35278  
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1  
;; OPT PSEUDOSECTION:  
; EDNS: version: 0, flags:; udp: 512  
;; QUESTION SECTION:  
;[smtp.gmail.com](http://smtp.gmail.com). IN A  
;; ANSWER SECTION:  
[smtp.gmail.com](http://smtp.gmail.com). 189 IN A 108.177.15.109  
;; Query time: 9 msec  
;; SERVER: 192.168.1.1#53(192.168.1.1)  
;; WHEN: Thu Oct 13 14:10:50 CEST 2022  
;; MSG SIZE rcvd: 59

**ping [smtp.gmail.com](http://smtp.gmail.com)**  
PING [smtp.gmail.com](http://smtp.gmail.com) (142.251.5.108) 56(84) bytes of data.  
64 bytes from [wg-in-f108.1e100.net](http://wg-in-f108.1e100.net) (142.251.5.108): icmp\_seq=1 ttl=102 time=33.4 ms  
64 bytes from [wg-in-f108.1e100.net](http://wg-in-f108.1e100.net) (142.251.5.108): icmp\_seq=2 ttl=102 time=33.5 ms

**ping6 [smtp.gmail.com](http://smtp.gmail.com)**  
ping6: connect: Network is unreachable

---

<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:** [13 October 2022 12:56 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/7 "2022-10-13T12:56:11Z")

</div>

> [@Switchblade2](#):
>
> 4: ztugayhmgh: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 2800 qdisc pfifo\_fast state UNKNOWN group default qlen 1000  
> link/ether [xx:xx:xx:xx:xx:xx] brd ff:ff:ff:ff:ff:ff  
> inet 172.22.185.220/16 brd 172.22.255.255 scope global ztugayhmgh  
> valid\_lft forever preferred\_lft forever  
> inet6 [fe80::xxxx:xxxx:xxxx:4f29]/64 scope link  
> valid\_lft forever preferred\_lft forever

Do you know what that is all about? Have you got two ethernet ports?  
If you have both wifi and ethernet connect try unplugging the ethernet and try disabling the wifi, with the ethernet plugged in.

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 13:56 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/8 "2022-10-13T13:56:33Z")

</div>

I have ZeroTier (an IoT VPN) installed, the info under 4. comes probably from there. Possibly it is the culprit?  
I only have wifi and I've de-connected and reconnected to the wifi, no change.  
I've added IPv6 Auto-Assign on ZeroTier and rebooted the Pi, no change.

---

<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:** [13 October 2022 14:40 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/9 "2022-10-13T14:40:06Z")

</div>

> [@Switchblade2](#):
>
> I've de-connected and reconnected to the wifi, no change.

So with the wifi disconnected you can still ping [smtp.gmail.com](http://smtp.gmail.com)? If so then it is using the vpn.

> [@Switchblade2](#):
>
> I have ZeroTier (an IoT VPN) installed, the info under 4. comes probably from there. Possibly it is the culprit?

Disable that and see what happens. Run ip addr to make sure it has gone.

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 15:58 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/10 "2022-10-13T15:58:39Z")

</div>

First I want to thank you for the time spent on this persisting error!

I've deleted Zerotier from the Raspberry, but still same error on the email node ...

ip addr  
1: lo: \<LOOPBACK,UP,LOWER\_UP\> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000  
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
inet 127.0.0.1/8 scope host lo  
valid\_lft forever preferred\_lft forever  
inet6 ::1/128 scope host  
valid\_lft forever preferred\_lft forever  
2: eth0: \<NO-CARRIER,BROADCAST,MULTICAST,UP\> mtu 1500 qdisc mq state DOWN group default qlen 1000  
link/ether dc:a6:32:76:1e:7c brd ff:ff:ff:ff:ff:ff  
3: wlan0: \<BROADCAST,MULTICAST,UP,LOWER\_UP\> mtu 1500 qdisc pfifo\_fast state UP group default qlen 1000  
link/ether dc:a6:32:76:1e:7d brd ff:ff:ff:ff:ff:ff  
inet 192.168.1.115/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0  
valid\_lft 86030sec preferred\_lft 75230sec  
inet6 fe80::1717:2813:a494:3759/64 scope link  
valid\_lft forever preferred\_lft forever

---

<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:** [13 October 2022 16:05 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/11 "2022-10-13T16:05:54Z")

</div>

It is very strange. I can only suggest disabling IPv6 completely in the pi.

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 16:27 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/12 "2022-10-13T16:27:29Z")

</div>

Disabling IPv6 and rebooting the Raspberry made it work again.  
Thanks for all help in finding a solution/workaround.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 October 2022 16:38 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/13 "2022-10-13T16:38:39Z")

</div>

How did you disable ipv6?

---

<div class="post-metadata">

**Author:** ![Switchblade2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/switchblade2/32/60655_2.png) [@Switchblade2](https://discourse.nodered.org/u/Switchblade2)\
**Post date:** [13 October 2022 16:44 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/14 "2022-10-13T16:44:17Z")

</div>

# Disabling IPv6

Source: [How to disable IPv6 on Raspberry Raspbian](https://www.leowkahman.com/2016/03/19/disable-ipv6-raspberry-raspbian/)

Firstly, check for presence of IPv6 using ifconfig. You should be seeing a few lines containing inet6 addr: ....

To disable, edit a file: `sudo nano /etc/sysctl.conf`

Add the following line:

```auto
net.ipv6.conf.all.disable_ipv6 = 1

```

For the change to take effect without rebooting: `sudo sysctl -p`

Verify that IPv6 address does not show up in ifconfig.

If you wish to re-enable, change the value in the setting above from 1 to 0 then execute the following two lines:

```auto
sudo sysctl -p
sudo ifconfig eth0 down && sudo ifconfig eth0 up

```

If you are doing this over SSH, the current session will of course be cut off. You should be able to reconnect in just a few seconds.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 October 2022 16:58 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/15 "2022-10-13T16:58:30Z")

</div>

Thanks.

I have three raspberry pies running node red, two can send email, one can't. And on that one, ifconfig shows an inet6 address.

Let's see if I can turn the problem on and off!

I presume that an ipv6 address does not come from the network's DHCP server (one of the pies) I wonder if that pi bypasses my pihole too.

---

<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:** [13 October 2022 20:24 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/16 "2022-10-13T20:24:07Z")

</div>

What we don't understand is why, apparently, the OS gives the email node an ipv6 address for the mail server.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [13 October 2022 22:15 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/17 "2022-10-13T22:15:34Z")

</div>

I have managed to introduce this problem to another of my Pies, by **apt full-upgrade** and a restart.

The upgraded packages include  
nodejs:arm64 (16.17.0-deb-1nodesource1, 16.17.1-deb-1nodesource1),

I'm trying to work out how to roll the upgrades back so I can be sure which is the guilty party.

Edit:  
I think I have proved that it's caused by nodejs 16.17.1 and going back to nodejs 14 clears it.

1. On a Raspberry Pi 4B which could not send gmail I rolled nodejs back to 14.20.1 using the Raspberry Pi install script - sending gmail works.
2. Upgrade to 16.17.1 using the install script - gmail still works.
3. Reboot - the bug is back!

My Pi which can still send gmail has nodejs 16.17.0,  
**sudo apt update** suggests the upgrade to 16.17.1  
**sudo apt -y full-upgrade** and a reboot introduced the bug on another Pi.

Edit 2:  
Maybe this is relevant [https://github.com/nodejs/node/issues/40702](https://github.com/nodejs/node/issues/40702)

> We have been having the same issue with node 17 and it appears to be a breaking change with how DNS.lookup works. With node 16, the lookup would return a IPv4 address but with node 17, it returns an IPv6 address which will break most REST clients that hardcode URLS like `http://localhost:4040/api` if the upstream server only binds to the IPv4 address (e.g. `server.listen('127.0.0.1'...)` etc..

Although that's about a change in nodejs 17, it does ring a bell re someone saying email works if you configure the node with an IP address rather than hostname.

---

<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:** [14 October 2022 06:23 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/18 "2022-10-14T06:23:44Z")

</div>

If you want to absolutely prove that it is the minor version that causes it you should be able to do

`apt install nodejs=16.17.0-deb-1nodesource1`

After setting the repository to 16 of course.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 October 2022 06:49 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/19 "2022-10-14T06:49:44Z")

</div>

> [@Colin](#):
>
> After setting the repository to 16 of course.

I didn't do that because I don't know how/what it means.

What I tried first of all:

```auto
sudo apt install nodejs:arm64=16.17.0-deb-1nodesource1
E: Version '16.17.0-deb-1nodesource1' for 'nodejs' was not found
sudo apt policy nodejs
nodejs:
  Installed: 16.17.1-deb-1nodesource1
  Candidate: 16.17.1-deb-1nodesource1
  Version table:
 *** 16.17.1-deb-1nodesource1 500
        500 https://deb.nodesource.com/node_16.x bullseye/main arm64 Packages
        100 /var/lib/dpkg/status
     12.22.12~dfsg-1~deb11u1 500
        500 http://security.debian.org/debian-security bullseye-security/main arm64 Packages
     12.22.5~dfsg-2~11u1 500
        500 http://deb.debian.org/debian bullseye/main arm64 Packages

```

.That's why I took the more radical approach of reinstalling Node-red

---

<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:** [14 October 2022 07:15 UTC](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971/20 "2022-10-14T07:15:50Z")

</div>

> [@jbudd](#):
>
> > [@Colin](#):
> >
> > After setting the repository to 16 of course.
> 
> I didn't do that because I don't know how/what it means.

I meant after installing v16, which sets the apt sources to use the v16 repository.

> [@jbudd](#):
>
> `E: Version '16.17.0-deb-1nodesource1' for 'nodejs' was not found`

That suggests they have removed that version from the repository, which surprises me.  
I can't check at the moment, will try to look later.

[Next page](https://discourse.nodered.org/t/error-connect-enetunreach-on-node-red-node-email/68971.md?page=2)
