You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
~/projects/tutorials/yournewapp $ node server.js
App listening on port 8080
events.js:141
throw er; // Unhandled 'error' event
^
Error: connection closed
at null. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:592:24)
at emitNone (events.js:67:13)
at emit (events.js:166:7)
at null. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:155:15)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:494:12)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at TCP._onclose (net.js:487:12)
The text was updated successfully, but these errors were encountered:
I thought I solved it in the past. I think we got this error because there was something running in port 8080. Try clossing other node's service running and tell me :) .
This error shows only when , you run server.js with "node server.js " command, then the applicationn start listenning 8080 port as it is indicates into code, after that the server try to connect database (mongodb), anyhow it can't connect to the database.
if you use
hostname
rather than IP address , hostname can't resolve. or or IP port can't reach.
If you use docker container to run the application, then use docker-compose. this will help you to resolve DNS or otherwise USE direct IP address. To test database connection try following instruction -
install mongodb driver to connect using IP , PORT or hostname , post which on you use.
Suppose , If you use Ubuntu then
apt-get install mongodb
mongo -h hostname/IP -p 27017
You will be able to connect mongodb, If you have user name and password then use mongo -u usename -p -h hostname -p 27017
~/projects/tutorials/yournewapp $ node server.js
App listening on port 8080
events.js:141
throw er; // Unhandled 'error' event
^
Error: connection closed
at null. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:592:24)
at emitNone (events.js:67:13)
at emit (events.js:166:7)
at null. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:155:15)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket. (/home/pat/projects/tutorials/yournewapp/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:494:12)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at TCP._onclose (net.js:487:12)
The text was updated successfully, but these errors were encountered: