gpt4 book ai didi

javascript - (7) 无法连接localhost端口3000 : Connection refused

转载 作者:行者123 更新时间:2023-12-02 21:10:30 25 4
gpt4 key购买 nike

我不明白为什么我无法使用以下代码创建服务器。

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com