How to fix Error: listen EADDRINUSE while using nodejs?

前端 未结 30 3737
执念已碎
执念已碎 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 06:48

    This works for me (I'm using mac). Run this command

    lsof -PiTCP -sTCP:LISTEN

    This's going to display a list of ports that your syetem is using. Find the PID that your node is running

    COMMAND     PID          USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    node      17269 hientrq   16u  IPv6 0xc42959c6fa30c3b9      0t0  TCP *:51524 (LISTEN)
    node      17269 hientrq   19u  IPv4 0xc42959c71ae86fc1      0t0  TCP localhost:1337 (LISTEN)
    

    and run kill -9 [YOUR_PID]

提交回复
热议问题