How to fix Error: listen EADDRINUSE while using nodejs?

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

    EADDRINUSE means that the port(which we try to listen in node application) is already being used. In order to overcome, we need to identify which process is running with that port.

    For example if we are trying to listen our node application in 3000 port. We need to check whether that port is already is being used by any other process.

    step1:

    $sudo netstat -plunt |grep :3000
    

    That the above command gives below result.

    tcp6       0      0 :::3000                 :::*                    LISTEN      25315/node
    

    step2:

    Now you got process ID(25315), Kill that process.

    kill -9 25315
    

    step3:

    npm run start
    

    Note: This solution for linux users.

提交回复
热议问题