How to fix Error: listen EADDRINUSE while using nodejs?

前端 未结 30 3981
执念已碎
执念已碎 2020-11-22 06:44

If I run a server with the port 80, and I try to use xmlHTTPrequest i get this error: Error: listen EADDRINUSE

Why is it problem for nodejs, if I want t

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 07:07

    For other people on windows 10 with node as localhost and running on a port like 3500, not 80 ...

    What does not work:

    killall    ?  command not found
    ps -aux | grep 'node'     ?     ps:  user x unknown 
    

    What shows information but still not does work:

     ps -aef | grep 'node'
     ps ax
     kill -9 61864
    

    What does work:

    Git Bash or Powershell on Windows

      net -a -o | grep 3500   (whatever port you are looking for) 
    

    Notice the PID ( far right )
    I could not get killall to work... so

    1. Open your task manager
    2. On processes tab , right click on Name or any column and select to include PID
    3. Sort by PID, then right click on right PID and click end task.

    Now after that not so fun exercise on windows, I realized I can use task manager and find the Node engine and just end it.

    FYI , I was using Visual Studio Code to run Node on port 3500, and I use Git Bash shell inside VS code. I had exited gracefully with Ctrl + C , but sometimes this does not kill it. I don't want to change my port or reboot so this worked. Hopefully it helps others. Otherwise it is documentation for myself.

提交回复
热议问题