Hi, i installed all modules and run "npm start" but it throws Error: [nodemon] 1.17.3
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node server.js
Could not connect to mongo server!
{ Error: Trying to open unclosed connection.
at NativeConnection.Connection._handleOpenArgs (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongoose\lib\connection.js:214:11)
at NativeConnection. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongoose\lib\connection.js:309:37)
at NativeConnection.deprecated [as open] (internal/util.js:52:15)
at Mongoose.connect (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongoose\lib\index.js:268:47)
at Object. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\model\model.js:15:10)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\controller\controller.js:1:76)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32) state: 2 }
(node:21828) DeprecationWarning: open() is deprecated in mongoose >= 4.11.0, use openUri() instead, or set the useMongoClient option if using connect() or createConnection(). See http://mongoosejs.com/docs/4.x/docs/connections.html#use-mongo-client
Node Server is setup and it is listening on http://192.168.1.22:8080
Could not connect to mongo server!
{ MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongodb-core\lib\topologies\server.js:336:35)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket. (C:\Users\User\Documents\Node-Projects\chat-example\Chat\node_modules\mongodb-core\lib\connection\connection.js:189:49)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
name: 'MongoError',
message: 'failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]' }
there is some issue with connecting to mongo. Is mongo running?
I have the same problem, any solution?
Try doing this.
MongoDB Atlas -> NetworkAccess -> Edit -> Allow Any