Sending email : "Error can not use ipv4 addresses with current network"

Just to add that I've just experienced this too yesterday.

I have 2 subnets and a rpi with node-red on each (both nr 3.0.2 and nodejs 16.17.1) one of my rPis was giving me this error, and the other not. Both could reach the internet. For me switching to the IP address of fixed it.

I went digging and found the code that triggers the error message here
nodemailer/index.js at master · nodemailer/nodemailer · GitHub @ line 219

I looked at the changelog for this file and tried to see if undoing some of the changes resolved the issue but I was unsuccessful.

The error is raised in a closed issue, though just 22 days ago with someone else experiencing it

And an earlier closed issue about accessing local interfaces which was added to the code

I've not managed to get to the bottom of this, but today when I've begun to look at it again - it is all working just fine on both machines again. I'm just wondering if somewhere there was some bad dns data that has expired and been refreshed, or perhaps my pihole interfered (recently updated) but I've not found any logs showing anything was blocked ---hmm.

Since this fails relatively silently I've got 2 nodes for an important email alert flow, one with the IP and one just in case


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

I am re-opening this as it is still a live issue.
I think that I may have determined the trigger. I think it can happen if node red starts up before the network is up and running, which is often the case if using wifi.
@julienD @sand_man @RandomSporadicProjs were you using wifi when this problem occurred?

I am doing some further tests to see if I can reliably create the problem.

1 Like

I am able to replicate it reliably on my system. I I disconnect the network and restart node red, then connect the network and try to send an email then I get the ipv4 error.

I have submitted an issue. Sending email "Error: Can not use IPv4 addresses with current network" · Issue #4114 · node-red/node-red · GitHub

Several possible answers here - feel free to try and report back

We already had an optional line in the service file in case someone needs to wait for time sync first... and indeed that may require DNS to work - so that may fix both situations... but is not a panacea as some users may not have internet access.

I though the had also determined it was to do with the fact node18 prioritises IPv6 over IPv4, and that was going to be re-visited.

1 Like

I think I would class those as workarounds rather than answers. Hopefully now that (for me at least) the problem can be reproduced, the underlying cause can be found.

So when the problem happens does it correct itself after a time ? IE once the DNS service is running then it works ok ?

No, it is necessary to restart node-red to make it recover.

Thanks for the info - though in my case both of the RPis I run are connected via ethernet - though my main one is also has pihole on it so I'll investigate the DNS availability check mentioned later in this thread

but pinging the address (by name) does work presumably ?
And is it just sending ? can you retrieve email ok ?


I don't know whether receiving works, I am not setup to receive email.

It does appear to be related to DNS, as others reported earlier, the problem does not appear if I use the IP address of the server.

1 Like

The nodemailer library does seem to suffer - GitHub - nodemailer/nodemailer: ✉️ Send e-mails with Node.JS – easy as cake! - I'm not sure what we can do to help them fix it.

Hi, thanks for your research.
My pi is connected with Ethernet.

I realised that your question and my answer were ambiguous. It could have meant ping in a command or ping in node red. In fact both of them recover when the network is restored, unlike the email node. Do you know whether node-red-node-ping uses nodejs to do the DNS lookup?
If it doesn't use nodejs do do the dns is there an simple way to find out whether it is the nodejs DNS that is broken or if it is specific to the email node?

Good thought. And no Sadly the ping node does in fact just shell out to the is ping command. So we need to find another node. I guess http request would.

I have tried the http request node and it behaves as expected. Recovering when the network is reconnected.

Would it be trivial for someone who knows what they are doing to knock up a function node using nodejs to do a dns lookup?


[{"id":"d1a5055351b39cd2","type":"inject","z":"fe51cb720c42b6e9","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":200,"y":450,"wires":[["fd28f1d954d39f50"]]},{"id":"fd28f1d954d39f50","type":"function","z":"fe51cb720c42b6e9","name":"function 1","func":"dns.resolve4(msg.payload, (\n    err, address) => node.warn('resolve4: '+ address)\n);\ndns.resolve6(msg.payload, (\n    err, address) => node.warn('resolve6: '+ address)\n);\ndns.lookup(msg.payload, (\n    err, address) => node.warn('lookup: '+ address)\n);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"dns","module":"dns"}],"x":435,"y":450,"wires":[[]]}]

and see docs for other options DNS | Node.js v18.15.0 Documentation

That works as I would expect, recovering after the network is restored to give the same as it does when the network was connected on restart, undefined for ipv6 and the correct address for ipv4 and for lookup.

Do you know if there is a reason that node-red-node-email is not pulling in the latest version of nodemailer (6.8.0 instead of 6.9.1) and smtp-server (which is pulled in by the node) is using nodemailer 6.7.3, which is earlier than the version fixing at least one of the bugs which have shown the same symptom, mentioned by @RandomSporadicProjs in post #21
Perhaps all it needs is an update of package.json on those.

bumped email node version. (It also now support OAuth authentication thanks to an incoming PR which we were testing)