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,288 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,840 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,840 points
20,244 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,840 points
1,672 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,840 points
3,178 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,840 points
1,697 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,840 points
1,489 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,840 points
1,041 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,840 points
2,469 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,840 points
9,353 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,840 points
4,163 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