i have this problem after i connect my file app.js with mongo database. when i use the command npm run watch or nodemon app it work for a second then that happened:
and this happened after i wrote this lines of code:
i tried to connect with new mongoDB account ..and it's the same
CodePudding user response:
That's because you are trying ot listen for connections on a port that is already in use. EADDRINUSE
.
Before mongoose.connect()
line, you are listening for connections on port 300
with app.listen(port)
.
Then after handling the promise success .then()
, you are doing the same, also listening for connections on the same port 300
with app.listen(port)
.
Solution:
Remove app.listen(port)
line before // for DB
comment.