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.

  

												

最新文章

  1. Fiddler 抓包工具总结
  2. Linux rpmbuild命令
  3. .net添加下拉框
  4. Oracle 11g 执行计划管理1
  5. Oracle数据库数据同步方案
  6. Ubuntu_14.04安装docker
  7. ckeditor与ckfinder简单整合使用
  8. Eucalyptus和Openstack最近版本的改动简单对比
  9. 英特尔的VT-d技术是什么?
  10. 小结css2与css3的区别
  11. 纯css3实现的动画导航菜单
  12. Oracle启动两个监听
  13. django模板系统(上)
  14. html css的内联样式 内部样式表 外部样式表的优先级
  15. dll(动态链接库)的编写
  16. 1.红黑树和自平衡二叉(查找)树区别 2.红黑树与B树的区别
  17. CF 557B(Pasha and Tea-贪心)
  18. Linux 配置samba服务实现与Windows文件共享
  19. 关于购买Redis服务器:腾讯云、阿里云还是华为云?
  20. 在ubuntu上配置LAMP架构

热门文章

  1. Linux 彻底删除用户
  2. 如何删除 Win10此电脑 desktop 视频 图片 文档 下载 音乐等文件夹
  3. Django 2.1版本与Django 1.8.3的一些区别(转)
  4. 019.Zabbix的Trigger及相关函数
  5. 001.VNC介绍
  6. 简单的CSS3 Loading动画
  7. Django(request和response)
  8. 怎样c# java md5值保持一致
  9. BZOJ2468 : [中山市选2010]三核苷酸
  10. BZOJ5020 [THUWC 2017]在美妙的数学王国中畅游LCT