Error listen EADDRINUSE while using nodejs

0 votes

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();
Apr 24, 2020 in Java-Script by kartik
• 37,520 points
1,239 views

1 answer to this question.

0 votes

Hello kartik,

Two possible solutions for this:

  1. Free currently used port number
  2. Select another port number for your current program

Your application is already running on that port 8080 . 

Use this code to kill the port and run your code again

sudo lsof -t -i tcp:8080 | xargs kill -9

Hope this works!!

Thank You!!

answered Apr 24, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to show progress bar while loading using ajax?

Hello @kartik, The first function calls an action ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
20,003 views
0 votes
1 answer

Getting error while validating email address in JavaScript

Hello @Eureka , You are missing jquery library. Add ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
1,499 views
+1 vote
1 answer

How to download a file from NodeJS Server using Express?

Hello @kartik, Express has a helper for this as: app.get('/download', function(req, ...READ MORE

answered Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
3,125 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,880 points
1,624 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,880 points
1,375 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,880 points
957 views
0 votes
1 answer

What are the important directories used in a common Laravel application

Hey @Kartik. Directories used in a common Laravel ...READ MORE

answered Mar 17, 2020 in Laravel by Niroj
• 82,880 points
2,332 views
0 votes
1 answer

Error: Unexpected token import in nodejs

Hello, Unfortunately, Node.js doesn't support ES6's import yet. To accomplish what ...READ MORE

answered Apr 24, 2020 in Java-Script by Niroj
• 82,880 points
9,178 views
+1 vote
1 answer

How to get error status code of http get NodeJS?

Hello @kartik, An error code 400 response is ...READ MORE

answered Jun 2, 2020 in Java-Script by Niroj
• 82,880 points
4,103 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP