How to fix Error: listen EADDRINUSE while using nodejs
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 to do a request, while I run a server on the port 80? For the webbrowsers it is not a problem: I can surf on the internet, while the server is running.
The server is:
net.createServer(function (socket) {
socket.name = socket.remoteAddress + ":" + socket.remotePort;
console.log('connection request from: ' + socket.remoteAddress);
socket.destroy();
}).listen(options.port);
And the request:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
sys.puts("State: " + this.readyState);
if (this.readyState == 4) {
sys.puts("Complete.\nBody length: " + this.responseText.length);
sys.puts("Body:\n" + this.responseText);
}
};
xhr.open("GET", "http://mywebsite.com");
xhr.send();
EADDRINUSE
means that the port number which listen()
tries to bind the server to is already in use.
So, in your case, there must be running a server on port 80 already.
If you have another webserver running on this port you have to put node.js behind that server and proxy it through it.
You should check for the listening
event like this, to see if the server is really listening:
var http=require('http');
var server=http.createServer(function(req,res){
res.end('test');
});
server.on('listening',function(){
console.log('ok, server is running');
});
server.listen(80);
解决方案:
What really helped for me was: killall -9 node
But this will kill a system process. With ps ax
you can check if it worked.
How to fix Error: listen EADDRINUSE while using nodejs的更多相关文章
- Error: listen EADDRINUSE
有可能是已经作用了18001端口 netstat -antp|grep 18001 kill 然后重启程序. events.js:72 throw er; // Unhandled 'error' e ...
- 启动项目报错Error: listen EADDRINUSE
我在使用elasticsearch的kibana插件时候,有一次启动,遇到这个错误: Error: listen EADDRINUSE 它的意思是,端口5601被其他进程占用. 故而,需要kill掉那 ...
- nuxt npm run dev 报错Solution to the "Error: listen EADDRINUSE 127.0.0.1:8080"
Solution to the "Error: listen EADDRINUSE 127.0.0.1:8080" Hello, Just sharing a solution t ...
- node服务端口被占用Error listen EADDRINUSE :::3000
Error: listen EADDRINUSE: address already in use :::3000,出现这个报错说明3000端口被占用 解决方法:找到占用该端口的程序,kill杀掉它就可 ...
- webpack dev server 配置 启动项目报错Error: listen EADDRINUSE
Error: listen EADDRINUSE 0.0.0.0:5601 它的意思是,端口5601被其他进程占用. 切换端口即可解决问题
- nodejs出现events.js:72中抛出错误 Error: listen EADDRINUSE
<pre>events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoExce ...
- 解决 Node.js 错误 Error:listen EADDRINUSE
第一次尝试 node.js 中的 express 框架,写了第一个 js 文件之后,在 WebStorm 运行,到游览器刷新,成功运行. 又创建一个 js 文件,写的是静态路由的访问,结果出现了 Er ...
- node本地服务启动报Error: listen EADDRINUSE解决方法
Error: listen EADDRINUSE 127.0.0.1:1337 at Object.exports._errnoException (util.js:1018:11) at expor ...
- 关于“Error: listen EADDRINUSE: address already in use 127.0.0.1:3000”
运行vue项目的时候报 Error: listen EADDRINUSE: address already 这个错,表示3000端口号被占用. 解决方法: 1.打开cmd,执行 netstat -n ...
随机推荐
- Gitlab-使用其它API资源
1. Users: 执行下面的任务去管理用户 List users Get, Create , edit, and delete a user List SSH keys for a given us ...
- 【转载】【收藏】Github上免费的编程教程【作者Victor Felder】
原链接:https://github.com/EbookFoundation/free-programming-books/blob/master/free-programming-books-zh. ...
- CentOS图形界面下如何安装Eclipse和使用maven
不多说,直接上干货! http://www.eclipse.org/downloads/packages/release/Kepler/SR2 下载到/usr/local/下,解压完成之后,我们想用这 ...
- java反射bean to bean
/** * Copyright © 2018 fwz Info. Tech Ltd. All rights reserved. * * @Package: com.sm.utils * @author ...
- JAVA 类和对象基础知识详解
/*文章中用到的代码只是一部分,需要源码的可通过邮箱联系我 1978702969@qq.com*/ 和C++一样,JAVA也是一门面向对象的语言,其基础和核心是类和对象.而面向对象的思想是来源与显示生 ...
- ABP单元测试
一.介绍 在本文中,我将介绍如何为基于ASP.NET Boilerplate的项目创建单元测试. 我将使用本文开发的相同的应用程序(使用AngularJs,ASP.NET MVC,Web API和En ...
- python集合相关操作
集合相关操作 集合是一个无序的,不重复的数据组合,它有着两个主要作用:去重以及关系测试. 去重指的是当把一个列表变成了集合,其中重复的内容就自动的被去掉了 关系测试指的是,测试两组数据之间的交集.差集 ...
- Redis学习笔记(1)- CentOS 6.4 安装Redis
Redis学习笔记(1)- CentOS 6.4 安装Redis 2013.10.13 学习环境 vm 10.1 + 默认.新装的干净 CentOS 6.4 64BIT系统 准备 1 ...
- BZOJ4275 : [ONTAK2015]Badania naukowe
设f[i][j]为a[1..i]与b[1..j]的LCS,g[i][j]为a[i..n]与b[j..m]的LCS. 若C为0,则ans=f[n][m]. 否则求出d[i]=a中从i开始往右匹配上c串的 ...
- HDU 5908 Abelian Period 暴力
Abelian Period 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5908 Description Let S be a number st ...