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 works for a second then that happens:
and this happened after I wrote this lines of code:
I tried to connect with new mongoDB account ..and it's the same
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)
.
Remove app.listen(port)
line before // for DB
comment.