Events.js: 72 error - Error running my first global app with express

Asked

Viewed 240 times

2

I did the global installation of express on Ubuntu (and on my Mac too) using

npm install -g express 

Then I created my app using the command:

express -se hello_express

I entered the application directory and typed:

npm install

When I try to run Node using the command

node app.js

he accuses the following error:

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: listen EADDRINUSE
  at errnoException (net.js:901:11)
  at Server._listen2 (net.js:1039:14)
  at listen (net.js:1061:10)
  at Server.listen (net.js:1135:5)
  at Object.<anonymous> (/caminho_da_aplicacao/hello_express/app.js:36:24)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)

I’m starting now with "Node + express," so I’d like to know if anyone’s been through this, if I’m doing something wrong, and how do I solve it.

  • 2

    You forgot to put precisely the code of your app, which is the most important

  • 1

    The code is the default, created automatically by express in app.js

1 answer

2


Error: listen EADDRINUSE

The port the express will use is already being used, choose another: the port is defined by that line app.set('port', process.env.PORT || 3000); in the app.js, soon change the variable PORT.

As has been shown on this Stackoverflow issue you will also encounter this error when you close your app unexpectedly, which is without the chance of the application releasing the ports. If this is your case there are the answers.

  • That was exactly the problem. I changed the value of the port which by default is 3000 to 4000 and worked correctly.

  • Good catch. I see this kind of mistake eventually and I didn’t even stop to see the detail of EADDRINUSE. That’s the same answer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.