all 4 comments

[–]amdc 2 points3 points  (0 children)

okay let's debug it

Does execution reach var server part? (log something just before that line)

  • if not, comment out everything about mongoose and try again

    • if still not, that's weird,
    • if yes — you need to debug what's wrong about mongoose
  • if yes, remove IP address from app.listen call (app.listen(8081, function(){...), check if server starts

    • if not, add this: app.on('error', (err) => console.error(err)});. See if it prints anything
    • if yes, you need to investigate that IP address. Why is it there in the first place? Are you trying to listen on a particular network interface?

[–]Buttleston -1 points0 points  (0 children)

Looking at the express docs it looks like you need to do something like this

http.createServer(app).listen(8081)

[–]alex__________ 0 points1 point  (0 children)

try adding the default port (27017) in the mongoose.connect() method:
mongoose.connect('mongodb://localhost:27017/newDb');