0

I am keep facing the below error when running the node server, but the code used to work properly before. Could any expert to resolve the issue?

Below is the error part of server.js

    try {
        app.listen(port, function(){
            console.log('Server started on port'+port);
        })
    } catch (e) {
        console.log('There was an error', e);
    }

-------------------------------error---------------------------------------
PS C:\Users\User\WebstormProjects\myapp> nodemon server
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server app.js`
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1024:11)
    at exports._exceptionWithHostPort (util.js:1047:20)
    at Server.setupListenHandle [as _listen2] (net.js:1319:14)
    at listenInCluster (net.js:1367:12)
    at Server.listen (net.js:1467:7)
    at Function.listen (C:\Users\User\WebstormProjects\myapp\node_modules\express\lib\application.js:618:24)
    at Object.<anonymous> (C:\Users\User\WebstormProjects\myapp\server.js:52:9)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
[nodemon] app crashed - waiting for file changes before starting...
  • 2
    Possible duplicate of [node.js express socket.io port 3000 in use](https://stackoverflow.com/questions/28184795/node-js-express-socket-io-port-3000-in-use) – Alexandru Olaru Aug 15 '17 at 07:35

2 Answers2

-1

Another app is already using port 3000. You can start it with another port.

Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54
-1

You app is working, maybe you just started it twice, you can try skill node & start it again, or change your variable port by 3001

nodeover
  • 301
  • 1
  • 2
  • 11