0

I hosted my NodeJs website on AWS Red Hat Linux but it's accessible from outside. although when i run my nodejs server from putty, it was running just fine. enter image description here

below is my server creation code in nodejs.I'm using express framework with jade.

app.listen(80, function () {
    console.log('Server starts on port: ' + 80);
});

I have opened all traffic from AWS console also and tried other ports as well.

ps -ef | grep node says:-

enter image description here

and app.log says:-

uncaughtException: Error: listen EADDRINUSE
Server starts on port: 80
Jitendra Pancholi
  • 7,897
  • 12
  • 51
  • 84

2 Answers2

0

You are getting this error as there is already a application that is using port 80 on your system, probably Apache or Nginx, so you should just use another port and configure your web-server to forward all HTTP requests to your port or just stop the webserver, also to use port 80 you need to use sudo so your commmand will be sudo node app.js. If you want to check what application is running on port 80 just use following commmand :

sudo netstat -tupln | grep 80

the output should show you what process is using your port you can kill it if you want

AJS
  • 1,993
  • 16
  • 26
  • not working, see http://stackoverflow.com/questions/40926433/aws-linux-ubuntu-hosted-application-is-not-accessible-from-public-ip – Jitendra Pancholi Dec 02 '16 at 06:52
  • the question you are pointing to is different as in it you ask that it is not accessible. Here you asked why are you getting this error **uncaughtException: Error: listen EADDRINUSE Server starts on port: 80** – AJS Dec 02 '16 at 07:36
0
app.listen(80,"0.0.0.0", function () {
console.log('Server starts on port: ' + 80);
});``

it should work always make sure your app is accessible over the network eg "0.0.0.0" parameterenter code here

Robert
  • 5,278
  • 43
  • 65
  • 115