How to fix Error: listen EADDRINUSE while using nodejs?

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

    Error reason: You are trying to use the busy port number

    Two possible solutions for Windows/Mac

    1. Free currently used port number
    2. Select another port number for your current program


    1. Free Port Number

    Windows

    1. netstat -ano | findstr :4200
    2. taskkill /PID 5824 /F
    

    Mac

    You can try netstat

    netstat -vanp tcp | grep 3000
    

    For OSX El Capitan and newer (or if your netstat doesn't support -p), use lsof

    sudo lsof -i tcp:3000
    

    if this does not resolve your problem, Mac users can refer to complete discussion about this issue Find (and kill) process locking port 3000 on Mac


    2. Change Port Number?

    Windows

    set PORT=5000
    

    Mac

    export PORT=5000
    

提交回复
热议问题