简体   繁体   中英

Why does using port 80 give error in node.js?

I am new to node.js. I am trying to run sudo node server.js using port 80. but I get Error: listen EADDRINUSE: address already in use :::80. But when check process running using command sudo lsof -i :80 . Nothing is shown. What may be the issue.

I will assume your app crashed or didn't exit cleanly.

Check if your node is already running with:

ps aux | grep node

Should list out all running node processes, you can then kill -9 PID to ensure everything closes.

您必须将sudolsof一起使用

sudo lsof -i:80 -t

In your case it can be the possibility that the port number you are trying to access is already in use in the background by some another process or server. So in order to get access to that port, you should try to kill the process that is using port 80. Kill all will kill all the node apps running. You might not want to do that. With this command you can kill only the one app that is listening on a known port.

If using unix try this command:

sudo fuser -k 80/tcp 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM