Port in Use NodeRed Error

Welcome to Node-RED
===================

16 Jul 13:26:26 - [info] Node-RED version: v3.0.0
16 Jul 13:26:26 - [info] Node.js  version: v16.16.0
16 Jul 13:26:26 - [info] Linux 5.15.0-41-generic x64 LE
16 Jul 13:26:27 - [info] Loading palette nodes
16 Jul 13:26:28 - [info] Dashboard version 3.1.7 started at /ui
16 Jul 13:26:28 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
16 Jul 13:26:28 - [info] Settings file  : /home/diego/.node-red/settings.js
16 Jul 13:26:28 - [info] Context store  : 'default' [module=memory]
16 Jul 13:26:28 - [info] User directory : /home/diego/.node-red
16 Jul 13:26:28 - [warn] Projects disabled : editorTheme.projects.enabled=false
16 Jul 13:26:28 - [info] Flows file     : /home/diego/.node-red/flows.json
16 Jul 13:26:28 - [warn] Encrypted credentials not found
16 Jul 13:26:28 - [error] Uncaught Exception:
16 Jul 13:26:28 - [error] Error: listen EADDRINUSE: address already in use 192.168.1.124:1880
    at Server.setupListenHandle [as _listen2] (node:net:1372:16)
    at listenInCluster (node:net:1420:12)
    at doListen (node:net:1559:7)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

diego@diego-HP-G42-Notebook-PC:~$ sudo lsof -i 
COMMAND     PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd-r   566 systemd-resolve   12u  IPv4  24122      0t0  UDP localhost:domain 
systemd-r   566 systemd-resolve   13u  IPv4  24123      0t0  TCP localhost:domain (LISTEN)
avahi-dae   598           avahi   12u  IPv4  28745      0t0  UDP *:mdns 
avahi-dae   598           avahi   13u  IPv6  28746      0t0  UDP *:mdns 
avahi-dae   598           avahi   14u  IPv4  28747      0t0  UDP *:38623 
avahi-dae   598           avahi   15u  IPv6  28748      0t0  UDP *:39039 
cupsd       600            root    6u  IPv6  25269      0t0  TCP ip6-localhost:ipp (LISTEN)
cupsd       600            root    7u  IPv4  25270      0t0  TCP localhost:ipp (LISTEN)
NetworkMa   602            root   23u  IPv4 298742      0t0  UDP diego-HP-G42-Notebook-PC:bootpc->Cisco06007:bootps 
cups-brow   693            root    7u  IPv4  26578      0t0  UDP *:631 
gvfsd-smb 17917           diego   10u  IPv4 163401      0t0  TCP diego-HP-G42-Notebook-PC:42582->Cisco06007:netbios-ssn (ESTABLISHED)
firefox   22817           diego   38u  IPv4 426685      0t0  TCP diego-HP-G42-Notebook-PC:43890->upload-lb.eqiad.wikimedia.org:https (ESTABLISHED)
firefox   22817           diego   61u  IPv4 301105      0t0  TCP diego-HP-G42-Notebook-PC:58762->ec2-34-214-236-46.us-west-2.compute.amazonaws.com:https (ESTABLISHED)
firefox   22817           diego  114u  IPv4 437500      0t0  TCP diego-HP-G42-Notebook-PC:60920->184.105.176.47:https (ESTABLISHED)
firefox   22817           diego  130u  IPv4 314637      0t0  TCP diego-HP-G42-Notebook-PC:52102->whatsapp-cdn-shv-02-mia3.fbcdn.net:https (ESTABLISHED)
firefox   22817           diego  159u  IPv4 432217      0t0  TCP diego-HP-G42-Notebook-PC:47660->151.101.4.193:https (ESTABLISHED)
firefox   22817           diego  203u  IPv4 433201      0t0  TCP diego-HP-G42-Notebook-PC:53212->bog02s14-in-f2.1e100.net:https (ESTABLISHED)
firefox   22817           diego  207u  IPv4 432230      0t0  TCP diego-HP-G42-Notebook-PC:43360->bog02s15-in-f1.1e100.net:https (ESTABLISHED)
firefox   22817           diego  211u  IPv4 433162      0t0  TCP diego-HP-G42-Notebook-PC:43364->bog02s15-in-f1.1e100.net:https (ESTABLISHED)
firefox   22817           diego  217u  IPv4 433218      0t0  TCP diego-HP-G42-Notebook-PC:47532->bog02s17-in-f2.1e100.net:https (ESTABLISHED)
firefox   22817           diego  231u  IPv4 432198      0t0  TCP diego-HP-G42-Notebook-PC:33780->bog02s16-in-f2.1e100.net:https (ESTABLISHED)
firefox   22817           diego  238u  IPv4 430071      0t0  TCP diego-HP-G42-Notebook-PC:40484->151.101.1.69:https (ESTABLISHED)
firefox   22817           diego  243u  IPv4 430526      0t0  TCP diego-HP-G42-Notebook-PC:45444->xx-fbcdn-shv-02-mia3.fbcdn.net:https (ESTABLISHED)
firefox   22817           diego  244u  IPv4 433164      0t0  TCP diego-HP-G42-Notebook-PC:58380->bog02s16-in-f1.1e100.net:https (ESTABLISHED)
firefox   22817           diego  254u  IPv4 433205      0t0  TCP diego-HP-G42-Notebook-PC:43262->vn-in-f156.1e100.net:https (ESTABLISHED)
node-red  39548           diego   18u  IPv4 425868      0t0  TCP diego-HP-G42-Notebook-PC:1880->ESP-3FDA2B:50989 (CLOSE_WAIT)
node-red  39548           diego   19u  IPv4 426270      0t0  TCP diego-HP-G42-Notebook-PC:1880 (LISTEN)

Idk how to solve it, everything is fine when ESP is not sending data but when it stats to do it the server overloads

We have been through that error a number of times. It is because node red is already running. If it is hogging the processor then after node-red-stop it may be a couple of minutes before node red stops. If it won't stop then reboot.

Start it in safe mode and break the flow (remove a wire) early in the flow that the ESP runs. Deploy and make sure the server is not overloaded. Join that wire back and break it a bit further on and deploy again. Keep doing it till you find why it is hanging.

idk if this is the issue

diego@diego-HP-G42-Notebook-PC:~$ ss --tcp state CLOSE-WAIT --kill
SOCK_DESTROY answers: Operation not permitted
SOCK_DESTROY answers: Operation not permitted
Recv-Q            Send-Q                         Local Address:Port                          Peer Address:Port             Process            
310               0                              192.168.1.124:1880                         192.168.1.122:50491                               
310               0                              192.168.1.124:1880                         192.168.1.122:62909                               
310               0                              192.168.1.124:1880                         192.168.1.122:55467                               
310               0                              192.168.1.124:1880                         192.168.1.122:57083                               
310               0                              192.168.1.124:1880                         192.168.1.122:55711                               
310               0                              192.168.1.124:1880                         192.168.1.122:61882                               
310               0                              192.168.1.124:1880                         192.168.1.122:63121                               
310               0                              192.168.1.124:1880                         192.168.1.122:54613                               
310               0                              192.168.1.124:1880                         192.168.1.122:61514                               
310               0                              192.168.1.124:1880                         192.168.1.122:65406                               
310               0                              192.168.1.124:1880                         192.168.1.122:52483                               
310               0                              192.168.1.124:1880                         192.168.1.122:63080                               
310               0                              192.168.1.124:1880                         192.168.1.122:59107                               
310               0                              192.168.1.124:1880                         192.168.1.122:64907                               
310               0                              192.168.1.124:1880                         192.168.1.122:64396                               
310               0                              192.168.1.124:1880                         192.168.1.122:63942                               
310               0                              192.168.1.124:1880                         192.168.1.122:55218                               
310               0                              192.168.1.124:1880                         192.168.1.122:55901                               
310               0                              192.168.1.124:1880                         192.168.1.122:52642                               
310               0                              192.168.1.124:1880                         192.168.1.122:63218                               
310               0                              192.168.1.124:1880                         192.168.1.122:59091                               
310               0                              192.168.1.124:1880                         192.168.1.122:63229                               
310               0                              192.168.1.124:1880                         192.168.1.122:61705                               
310               0                              192.168.1.124:1880                         192.168.1.122:64180                               
310               0                              192.168.1.124:1880                         192.168.1.122:59068                               
310               0                              192.168.1.124:1880                         192.168.1.122:60764                               
310               0                              192.168.1.124:1880                         192.168.1.122:55357                               
310               0                              192.168.1.124:1880                         192.168.1.122:50586                               
310               0                              192.168.1.124:1880                         192.168.1.122:65387                               
310               0                              192.168.1.124:1880                         192.168.1.122:55079                               
310               0                              192.168.1.124:1880                         192.168.1.122:61878                               
310               0                              192.168.1.124:1880                         192.168.1.122:58084                               
310               0                              192.168.1.124:1880                         192.168.1.122:51888                               
310               0                              192.168.1.124:1880                         192.168.1.122:61546                               
310               0                              192.168.1.124:1880                         192.168.1.122:56403                               
310               0                              192.168.1.124:1880                         192.168.1.122:63441                               
310               0                              192.168.1.124:1880                         192.168.1.122:61145                               
310               0                              192.168.1.124:1880                         192.168.1.122:55469                               
310               0                              192.168.1.124:1880                         192.168.1.122:50790                               
310               0                              192.168.1.124:1880                         192.168.1.122:52607                               
310               0                              192.168.1.124:1880                         192.168.1.122:50956                               
310               0                              192.168.1.124:1880                         192.168.1.122:60882                               
310               0                              192.168.1.124:1880                         192.168.1.122:54739                               
310               0                              192.168.1.124:1880                         192.168.1.122:51983                               
310               0                              192.168.1.124:1880                         192.168.1.122:57523                               
1                 0                              192.168.1.124:1880                         192.168.1.122:52365           

Remember that once node-red hangs up everything will run slow, including the networking.
How did you get on with the suggestions in my previous post?

That is an understatement... depending on the device, it can lock things up so well, that it is struggle to just get NR stopped. Have done a few times over the years!

There is a specific socket mode you can use to get the Linux OS to try and I stress try to re-use ports that are hung or less than gracefully abandoned, but this is tricky even in the best of circumstances.

https://man7.org/linux/man-pages/man7/socket.7.html

Reference: " Linux will allow port reuse only with the SO_REUSEADDR option when this option was set both in the previous program that performed a bind(2) to the port and in the program that wants to reuse the port."

But there maybe not be a straight-forward way to leverage this feature within NR, have not had chance to dig into it as yet. I had some issues with using UDP port 9 recently when I wrote a flow to monitor WOL packet deployment, so was going to get back to using SO_REUSEADDR at some point. Used it all the time when I was writing C based socket based solutions.

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