Port in Use NodeRed Error

hi, I´ve already installed node red 3.0, because I was having trouble with the previous version about this problem, but the issue persists. I´ve tried to fix it killing the process but when I start the server again it works for a few minutes and then no more.

stop old running node-red by node-red-stop then try node-red-start

if that doesnt work, reboot (to release hold on port 1880)

oh - i just noticed you are running nodejs v10 - good luck with that. It is designed and tested on nodejs v14 and above only (anything less is unsupported)

1 Like

what version of node-red is suitable for nodejs v10?

I would recommend NodeJS v16 LTS for node-red v3

nodejs v12 for node-red V2.x

nodejs v10 for node-red V1.x

BUT nodejs - v10 and v12 are END OF LIFE (unsupported - so I wont run any of those)

1 Like

thnx I'll upgrade it to the newest version but its recommended to do that in a HP Pavilion G62 - Intel Core i3 with 4GB of RAM?.

What OS are you running on?

ubuntu 20.04

Ive just updated node js to v.16 but the problem still presists

Run
node-red-start
node-red-stop
and post the full output of both commands here. Please copy/paste the text, not screenshot. Use the </> button at the top of the forum entry window when pasting it.


diego@diego-HP-G42-Notebook-PC:~$ top

top - 15:20:07 up  1:25,  1 user,  load average: 1,27, 0,72, 0,33
Tareas: 207 total,   2 ejecutar,  205 hibernar,    0 detener,    0 zombie
%Cpu(s): 25,5 usuario,  1,3 sist,  0,0 adecuado, 73,2 inact,  0,0 en espera,  0,0 hardw int,  0,0 softw int,  0,0 robar tiempo
MiB Mem :   3724,7 total,    199,9 libre,   1010,6 usado,   2514,2 búfer/caché
MiB Intercambio:   2048,0 total,   2048,0 libre,      0,0 usado.   2339,4 dispon Mem 

    PID USUARIO   PR  NI    VIRT    RES    SHR S  %CPU  %MEM     HORA+ ORDEN                                                                  
   3033 diego     20   0  952432  98564  35196 R 100,0   2,6   4:52.56 node-red                                                               
    849 diego     20   0  340204  60228  31016 S   3,4   1,6   0:09.82 Xorg                                                                   
   1114 diego     20   0 4259244 233272  86984 S   1,7   6,1   0:27.94 gnome-shell                                                            
   2993 diego     20   0  818432  52152  39028 S   1,7   1,4   0:02.90 gnome-terminal-                                                        
   3557 root      20   0       0      0      0 I   1,7   0,0   0:00.46 kworker/u16:2-events_unbound                                           
   3666 diego     20   0   14728   4248   3436 R   1,7   0,1   0:00.03 top                                                                    
      1 root      20   0  169548  12808   8316 S   0,0   0,3   0:06.26 systemd                                                                
      2 root      20   0       0      0      0 S   0,0   0,0   0:00.00 kthreadd                                                               
      3 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_gp                                                                 
      4 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_par_gp                                                             
      5 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 netns                                                                  
      9 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 mm_percpu_wq                                                           
     10 root      20   0       0      0      0 S   0,0   0,0   0:00.00 rcu_tasks_rude_                                                        
     11 root      20   0       0      0      0 S   0,0   0,0   0:00.00 rcu_tasks_trace                                                        
     12 root      20   0       0      0      0 S   0,0   0,0   0:00.15 ksoftirqd/0                                                            
     13 root      20   0       0      0      0 I   0,0   0,0   0:01.33 rcu_sched                                                              
     14 root      rt   0       0      0      0 S   0,0   0,0   0:00.03 migration/0                                                            
     15 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/0                                                          
     17 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/0                                                                
     18 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/1                                                                
     19 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/1                                                          
     20 root      rt   0       0      0      0 S   0,0   0,0   0:00.28 migration/1                                                            
     21 root      20   0       0      0      0 S   0,0   0,0   0:01.44 ksoftirqd/1                                                            
     23 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 kworker/1:0H-kblockd                                                   
     24 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/2                                                                
     25 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/2                                                          
     26 root      rt   0       0      0      0 S   0,0   0,0   0:00.29 migration/2                                                            
     27 root      20   0       0      0      0 S   0,0   0,0   0:00.12 ksoftirqd/2                                                            
     29 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 kworker/2:0H-kblockd                                                   
     30 root      20   0       0      0      0 S   0,0   0,0   0:00.00 cpuhp/3                                                                
     31 root     -51   0       0      0      0 S   0,0   0,0   0:00.00 idle_inject/3                                                          
diego@diego-HP-G42-Notebook-PC:~$ sudo kill -9 3033
diego@diego-HP-G42-Notebook-PC:~$ 
diego@diego-HP-G42-Notebook-PC:~$ 
diego@diego-HP-G42-Notebook-PC:~$ node-red-start
node-red-start: no se encontró la orden
diego@diego-HP-G42-Notebook-PC:~$ node-red start
15 Jul 15:20:41 - [info] 

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

15 Jul 15:20:41 - [info] Node-RED version: v3.0.0
15 Jul 15:20:41 - [info] Node.js  version: v16.16.0
15 Jul 15:20:41 - [info] Linux 5.15.0-41-generic x64 LE
15 Jul 15:20:41 - [info] Loading palette nodes
15 Jul 15:20:42 - [info] Dashboard version 3.1.7 started at /ui
15 Jul 15:20:42 - [info] Settings file  : /home/diego/.node-red/settings.js
15 Jul 15:20:42 - [info] Context store  : 'default' [module=memory]
15 Jul 15:20:42 - [info] User directory : /home/diego/.node-red
15 Jul 15:20:42 - [warn] Projects disabled : editorTheme.projects.enabled=false
15 Jul 15:20:42 - [info] Flows file     : /home/diego/.node-red/start
15 Jul 15:20:42 - [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.
---------------------------------------------------------------------

15 Jul 15:20:42 - [warn] Encrypted credentials not found
15 Jul 15:20:42 - [info] Server now running at http://192.168.1.124:1880/
15 Jul 15:20:42 - [info] Starting flows
15 Jul 15:20:42 - [info] Started flows
15 Jul 15:20:42 - [error] [MySQLdatabase:DB_smartmeter] Error: connect ECONNREFUSED 127.0.0.1:3306
express deprecated res.status("200"): use res.status(200) instead ../../usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/21-httpin.js:328:34
^C^C

node-red is using 100% of CPU. You need to find out what is causing that. That is probably at the root of the problem. Possibly start by disabling tabs and watching the processor.

That is the correct command (not node-red start, which runs a flows file called start). The fact that the command is not found means that you did not install using the recommended ubuntu/debian/pi script. Though that is probably not causing the problem you are seeing.
https://nodered.org/docs/getting-started/raspberrypi

However, I don't know know which problem you think you have. Your initial problem was the port issue, which was due to the fact that node-red was already running, but you seem to have sorted that by killing the previous version (which is not good, it would be better to run the install script in the link I posted, then you could use the commands I posted)

Running Node-RED install for user diego at /home/diego on ubuntu


This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔   
  Install Node.js 16 LTS              ✔   v16.16.0   Npm 8.11.0
  Clean npm cache                     ✔
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.local          
  Install Node-RED core               ✔   3.0.0
  Move global nodes to local          -
  Npm rebuild existing nodes          ✔
  Install extra Pi nodes              ✔
  Add shortcut commands               ✔
  Update systemd script               ✔
Any errors will be logged to   /var/log/nodered-install.log


All done.
You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started :  vie 15 jul 2022 16:32:59 -05 
Finished:  vie 15 jul 2022 16:34:24 -05
 
Just FYI : Your settings.js file is different from the latest defaults.
You may wish to run
   diff -y --suppress-common-lines /usr/lib/node_modules/node-red/settings.js /home/diego/.node-red/settings.js
to compare them and see what the latest options are.

Ive follow all the steps in the documentation but i cant access to the editor via browser and node-red-stop runs but doesnt kill the process

Three questions.

  1. What does this command show?
    sudo systemctl status nodered (note, nodered not node-red)

  2. How are you starting node-red? Show me the exact command.

  3. Is node-red still consuming 100% of the CPU (or close to it)?


diego@diego-HP-G42-Notebook-PC:~$ sudo systemctl status nodered
● nodered.service - Node-RED graphical event wiring tool
     Loaded: loaded (/lib/systemd/system/nodered.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-07-15 22:09:48 -05; 13h ago
       Docs: http://nodered.org/docs/hardware/raspberrypi.html
   Main PID: 29419 (node-red)
      Tasks: 11 (limit: 4381)
     Memory: 66.3M
     CGroup: /system.slice/nodered.service
             └─29419 node-red

jul 15 22:09:50 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:09:50 - [warn] Encrypted credentials not found
jul 15 22:09:50 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:09:50 - [info] Server now running at http://192.168.1.124:1880/
jul 15 22:09:50 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:09:50 - [info] Starting flows
jul 15 22:09:51 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:09:51 - [info] Started flows
jul 15 22:21:11 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:21:11 - [info] Stopping flows
jul 15 22:21:11 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:21:11 - [info] Stopped flows
jul 15 22:21:11 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:21:11 - [info] Updated flows
jul 15 22:21:11 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:21:11 - [info] Starting flows
jul 15 22:21:11 diego-HP-G42-Notebook-PC Node-RED[29419]: 15 Jul 22:21:11 - [info] Started flows
jul 16 11:09:27 diego-HP-G42-Notebook-PC Node-RED[29419]: Sat, 16 Jul 2022 16:09:27 GMT express deprecated res.status("200"): use res.status(>


diego@diego-HP-G42-Notebook-PC:~$ node-red-start 

Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.1.124:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
Sat, 16 Jul 2022 16:09:27 GMT express deprecated res.status("200"): use res.status(200) instead at ../../usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/21-httpin.js:328:34
^C
diego@diego-HP-G42-Notebook-PC:~$ top

top - 11:19:34 up 21:24,  1 user,  load average: 1,13, 1,09, 0,81
Tareas: 230 total,   2 ejecutar,  228 hibernar,    0 detener,    0 zombie
%Cpu(s): 25,8 usuario,  0,5 sist,  0,0 adecuado, 73,5 inact,  0,1 en espera,  0,0 hardw int,  0,1 softw int,  0,0 robar tiempo
MiB Mem :   3724,7 total,    320,7 libre,   1637,3 usado,   1766,6 búfer/caché
MiB Intercambio:   2048,0 total,   1862,8 libre,    185,2 usado.   1649,2 dispon Mem 

    PID USUARIO   PR  NI    VIRT    RES    SHR S  %CPU  %MEM     HORA+ ORDEN                                                                  
  29419 diego     20   0  955224  98816  35440 R 100,3   2,6  10:11.63 node-red                                                               
    849 diego     20   0  359588  65800  34692 S   1,0   1,7   7:37.32 Xorg                                                                   
   1114 diego     20   0 4278076 226936  73328 S   1,0   5,9   7:54.42 gnome-shell                                                            
  33156 diego     20   0   14740   4112   3320 S   0,7   0,1   0:02.79 top                                                                    
    206 root      20   0       0      0      0 S   0,3   0,0   0:05.95 usb-storage                                                            
    336 root      20   0       0      0      0 S   0,3   0,0   0:04.39 ips-monitor                                                            
    837 diego      9 -11 3771740  16240  13272 S   0,3   0,4   2:16.41 pulseaudio                                                             
    984 root      20   0  255040   9668   8424 S   0,3   0,3   0:01.42 upowerd                                                                
   2993 diego     20   0  830848  50884  35568 S   0,3   1,3   1:14.05 gnome-terminal-                                                        
  29558 diego     20   0  452988   8028   6468 S   0,3   0,2   0:00.91 sd_espeak-ng                                                           
  30744 root      20   0       0      0      0 I   0,3   0,0   0:02.18 kworker/u16:23-events_unbound                                          
      1 root      20   0  169536  12656   8112 S   0,0   0,3   0:22.85 systemd                                                                
      2 root      20   0       0      0      0 S   0,0   0,0   0:00.04 kthreadd                                                               
      3 root       0 -20       0      0      0 I   0,0   0,0   0:00.00 rcu_gp  

So as you can see node-red is still consuming all the processor. If you run
node-red-stop
node-red --safe
then it will load the flows but not run them. Then you should be able to get into the editor so you can remove whatever is causing the processor overload. When you deploy it will start running the flows.

Having done this several times... I suggest once you have the editor open, disable EVERY flow, and then selectively enable them and test each as an individual test. This should set a baseline for each flow load. Then selectively enable additional flows and test. It is often the total concurrent flows running that slam the hosting system, unless you happen to have a specific poorly behaving flow.

This is is typical of how docker images, virtual machines, etc. all have to be evaluated in a peer to peer context to find the 'tipping' point. In the case of virtualization of entire virtual machines or just application level containers, i.e. docker, there are 100s of tools that allow for balancing and evaluating peer to peer processes.

I have not done any research, but if there is a Node level tool that can qualify peer to peer threading/processing under Node, that might be one way to get a better view of the load conflicts.

Im using a HTTP IN node to receive the information of my ESP 8266 via HTTP POST, It was working fine but 1 month later this problem occurred.

Sounds like, some software update, changed the context of the environment. My gut level approach is to always break out issues as hardware or software based, split. Meaning if nothing in the hardware has changed, at all, including firmware, drivers, etc. Look to the entire software stack applicable. #1 Know what you don't know... i.e. make no assumptions, at all.