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

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?

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.

I'm sending via gmail.
Server: smtp.gmail.com
Port: 465
Use secure connection: ticked

PING 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

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

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" - no-one has totally pinned it down yet.

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

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

from Running on Raspberry Pi : Node-RED

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
; <<>> DiG 9.16.33-Raspbian <<>> 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. IN A
;; ANSWER SECTION:
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
PING smtp.gmail.com (142.251.5.108) 56(84) bytes of data.
64 bytes from 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 (142.251.5.108): icmp_seq=2 ttl=102 time=33.5 ms

ping6 smtp.gmail.com
ping6: connect: Network is unreachable

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.

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.

So with the wifi disconnected you can still ping smtp.gmail.com? If so then it is using the vpn.

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

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

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

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

How did you disable ipv6?

Disabling IPv6

Source: How to disable IPv6 on 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:

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:

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.

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.

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

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

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.

1 Like

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.

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

What I tried first of all:

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

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

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.

1 Like