我不明白为什么我无法使用以下代码创建服务器。
var http = require('http');
var server = http.createServer ( function(req,res){
res.end('Hello World\n');
});
server.listen(3000,function(){
console.log("The server is listening on port 3000 now");
});
最佳答案
如果您使用的是unix系统,列出监听端口3000的所有进程:
lsof -i:3000
终止任何监听端口 3000 的进程:
kill $(lsof -t -i:3000)
强制暴力终止任何进程:
kill -9 $(lsof -t -i:3000)
然后再次运行脚本
关于javascript - (7) 无法连接localhost端口3000 : Connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61112042/