EADDRINUSE error

Hi, I'm trying to launch wore-red from terminal but this is the error I get

25 Nov 17:24:18 - [info]

Welcome to Node-RED

25 Nov 17:24:18 - [info] Node-RED version: v0.19.4
25 Nov 17:24:18 - [info] Node.js version: v8.11.1
25 Nov 17:24:18 - [info] Linux 4.14.79-v7+ arm LE
25 Nov 17:24:21 - [info] Loading palette nodes
25 Nov 17:24:26 - [info] Dashboard version 2.11.0 started at /ui
25 Nov 17:24:27 - [info] Settings file : /usr/lib/node_modules/node-red/settings.js
25 Nov 17:24:27 - [info] Context store : 'default' [module=memory]
25 Nov 17:24:27 - [info] User directory : /home/pi/.node-red
25 Nov 17:24:27 - [warn] Projects disabled : editorTheme.projects.enabled=false
25 Nov 17:24:27 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
25 Nov 17:24:27 - [info] Server now running at http://127.0.0.1:1880/
25 Nov 17:24:27 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

25 Nov 17:24:27 - [info] Starting flows
25 Nov 17:24:29 - [info] Started flows
25 Nov 17:24:29 - [red] Uncaught Exception:
25 Nov 17:24:29 - Error: listen EADDRINUSE :::1880
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1367:14)
at listenInCluster (net.js:1408:12)
at Server.listen (net.js:1492:7)
at EventedHTTPServer.listen (/home/pi/.node-red/node_modules/node-red-contrib-homekit/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19)
at HAPServer.listen (/home/pi/.node-red/node_modules/node-red-contrib-homekit/node_modules/hap-nodejs/lib/HAPServer.js:158:20)
at Accessory.publish (/home/pi/.node-red/node_modules/node-red-contrib-homekit/node_modules/hap-nodejs/lib/Accessory.js:607:16)
at new HAPServiceNode (/home/pi/.node-red/node_modules/node-red-contrib-homekit/homekit.js:79:17)
at createNode (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:305:18)
at Flow.start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:89:35)
at start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:328:29)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)

Any pointers? Looks like port 1880 is already in use, I think it happened after a deploy crashed.

Thanks
Lorenzo

I assume this is a Raspberry Pi.

Have you tried to restart ?

How did you perform the install ?? - with the standard script for Node-red etc ?

How are you starting Node-red on the machine normally ?

You could also try

netstat | grep 1880 to see what is attach to that port and then also

ps aux | grep node-red

this will show you if node-red is running and what user it is running under - it will also provide the process ID for you to kill it

Craig

That almost certainly means that node-red is already running. As others have suggested then try a reboot.

Rebooting is the first thing I tried. What I see is in the task manager a node process that keeps being created and it crashes on the terminal after a few seconds. It keeps restarting and crashes continuously.

In a terminal run

node-red-stop
node-red-start

and see what happens. Post the output here if necessary.

Tried that, always the same thing happens: same console output and in the task manager a new "node" process is created, which stays there for a few seconds then it disappears and it gets recreated with different ID. Cycling endlessly.

what happens if you pgrep node ? Is there already an instance of node running.
If not then try node-red blank.json to try starting Node-RED with a new blank flow file...
If that then runs - stop it and then retry with just node-red (so it will use you existing flow file)...
If that then dies then there is something corrupt or a bad node in your flow file. If so you can start with the blank again, load your "old" flow file in an editor - and cut and paste it into the blank flow ( but not hit deploy... until you have worked out what is broken).

1 Like

thanks a lot, I haven't tried this solution; I'll try it and let you know!

I have just been looking at the log you posted at the start again. I don't think there is another node-red process running. The server starts up ok listening on port 1880 then a couple of seconds later the crash occurs, apparently to do with node-red-contrib-homekit, which seems to be trying to start another server on the same port. I suspect that is where the issue is.
[Edit] You said the problem occurred initially when it crashed during a deploy. Was that when you attempted to deploy the homekit node, possibly you have specified port 1880 there, and there is a bug in the homekit node that does not trap the address in use error.

that is correct, there's no other node-red process running. I already had a flow with homekit nodes deployed, I added/modified something and then it crashed. Since then, this keeps happening and node-red cannot launch. kinda frustrating

In that case follow @dceejay's advice.

As per my original question - what are you using to run Node-red - PM2 ? or some other startup script ?

If it is PM2 - you have probably reset it to always restart - so even though Node-red crashes it will try and start it agaiin and go in an endless loop

Craig

no script to launch it, just node-red from the terminal.

Assuming you have the standard Pi install using the install script from the docs then it will be using systemd to start node red. When you run node-red-stop or start that is using the systemd script. That script will automatically restart node-red if it fails which explains why it keeps restarting.
Have you tried it with a blank flow as suggested by @dceejay? Run node-red-stop first to make sure it is not already running.

I've already tried running node-red-stop and the same keeps happening. The only thing I have left to try is @dceejay's solution, which I'll try later today. I'll let you know and thanks for the many feedbacks!

so, turns out the actual problem was in my flows; I launched node-red with a blank flows file and it worked, then launched again my original file and it died. So, I wiped my flows file and it works again. Luckily I had exported my flows so I saved 99% of my work.

Thanks everyone for the help!

You should have been able to Import/paste back in your broken flw and try to fix it up... but yes backups always good..

There is actually a one level backup kept as .flows_{yourflowname}.json.backup which is the previous version before deploy - so sometimes that can just be renamed flows_{yourflowname}.json to get you going again.

I am facing the exact same problem as yours, how did u wipe your flows file? Pls help

How to import it, pls explain.

Which exact same problem? Whatever it is it is node-red has moved on a lot in the last two years so the cause may well not be the same. Please start a new thread and tell us what is happening. Also tell us what OS you are using and how you installed node-red.