nodejs 端口号被占用

来源:互联网 发布:淘宝怎么回到基础班 编辑:程序博客网 时间:2024/06/05 05:56


使用nodejs做了个服务器测试

var http=require("http");http.createServer(function(request,response){        response.writeHead(200,{'Content-Type':'text/plain'});    response.end('Hello World\n');}).listen(8888);console.log('Server running at http://127.0.0.1:8888/');


出现如下错误



原因:

Eaddrinuse  地址使用错误  

本处,端口号被别的程序占用了

方法一:   换一个端口号 比如8889

方法二:   将占用这个端口的程序关掉

那么问题来了,怎么查看端口的占用情况,怎么知道哪个程序占用了这个端口呢?
使用如下方式:


C:\>netstat -aon|findstr "9050"TCP    127.0.0.1:9050         0.0.0.0:0              LISTENING       2016

看到了吗,端口被进程号为2016的进程占用,继续执行下面命令:C:\>tasklist|findstr "2016"tor.exe                     2016 Console                 0     16,064 K

在本例中,我们查找8888端口

F:\node>netstat -aon|findstr "8888"  TCP    0.0.0.0:8888           0.0.0.0:0              LISTENING       2496F:\node>tasklist|findstr "2496"matlabserver.exe            2496 Console                 0     13,648 K

然后将matlabserver.exe关掉,重新使用NODE 运行就可了。



原创粉丝点击