Node-RED重启后出现udp.errors.alreadyused错误求助
udp.errors.alreadyused Error After Restart Hey there, I’ve run into this exact frustrating issue before—everything was working smoothly with Node-RED and UDP, then a random restart throws this port conflict error. Let’s walk through the most reliable fixes step by step:
Check which process is holding your UDP port
First, you need to confirm what’s using the port your Node-RED flow depends on. Use these OS-specific commands (replace<your-udp-port>with the port number in your UDP node):- Windows: Run
netstat -ano | findstr :<your-udp-port> - Linux/macOS: Use
lsof -i :<your-udp-port>orss -ulpn | grep :<your-udp-port>
The output will show you the process ID (PID) of whatever’s hogging the port.
- Windows: Run
Kill stale Node-RED processes (the most common culprit)
Nine times out of ten, this error happens because a previous Node-RED instance didn’t shut down properly and is still holding the port. Once you have the PID from the step above, terminate it:- Windows:
taskkill /F /PID <process-id> - Linux/macOS:
kill -9 <process-id>
Restart Node-RED after this, and the error should vanish.
- Windows:
Switch to an unused UDP port
If another application is using your original port (not a Node-RED leftover), open your Node-RED editor, find all UDP input/output nodes in your flow, update their port number to an unused one (e.g., 5001 if you were using 5000), then re-deploy your flow.Enable address reuse in your UDP node
Many Node-RED UDP nodes have an option labeled "Allow address reuse". Enabling this lets the node bind to the port even if it’s in a TIME_WAIT state (a common scenario after improper shutdowns). Just edit the UDP node, check that box, and re-deploy.
Pro tip: Next time you restart Node-RED, use the proper shutdown method—either click the menu next to "Deploy" in the editor and select "Stop", or run node-red-stop from the command line. This helps prevent leftover processes from clinging to ports.
内容的提问来源于stack exchange,提问作者Vinod Poorma

