How to fix Error: listen EADDRINUSE while using nodejs?

前端 未结 30 3980
执念已碎
执念已碎 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:09

    Under a controller env, you could use:

    pkill node before running your script should do the job.

    Bear in mind this command will kill all the node processes, which might be right if you have i.e a container running only one instance, our you have such env where you can guarantee that.

    In any other scenario, I recommend using a command to kill a certain process id or name you found by looking for it programmatically. like if your process is called, node-server-1 you could do pkill node-server-1.

    This resource might be useful to understand: https://www.thegeekstuff.com/2009/12/4-ways-to-kill-a-process-kill-killall-pkill-xkill/

提交回复
热议问题