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();
What really helped for me was:
But this will kill a system process.
With
you can check if it worked.
Try both commands and it will stop all node process.
I have the same problem too,and I simply close the terminal and open a new terminal and run
again. that works for me, some time just need to wait for a few second till it work again.
But this works only on a developer machine instead of a server console..
In my case I use a web hosting but it´s the same in local host, I used:
for watch the node process then, the console shows the process with PID. for kill the process you have to use this command:
where PID is the process id from the command above.
Two servers can not listen on same port, so check out if other server listening on same port, also check out for browser sync if its running on same port
This error comes when you have any process running on a port on which you want to run your application.
how to get which process running on that port=> command: sudo netstat -ap | grep :3000
output : you will get the process information which is using that port
tcp 0 0 IPaddress:3000 : LISTEN 26869/node
Now you can kill that process sudo kill -9 26869