How to solve running node server error

Home / Uncategorized / How to solve running node server error

Question:
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:UsersUserWebstormProjectsmyapp> 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:UsersUserWebstormProjectsmyappnode_modulesexpresslibapplication.js:618:24)
at Object. (C:UsersUserWebstormProjectsmyappserver.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…


Answer:
Another app is already using port 3000. You can start it with another port.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *