Hyper-v
How to Connect Node.JS with MongoDB using Mongoose | Connect to a
How to Connect Node.JS with MongoDB using Mongoose | Connect to a MongoDB Database Using Node.js
#Connect #Node.JS #MongoDB #Mongoose #Connect
“Code With Yousaf”
#mongodb #nodejs #connection
This video is about How to Connect Node.JS with MongoDB using Mongoose | Connect to a MongoDB Database Using Node.js.
MongoDB Installation in Windows Locally:
First MERN Stack APP :
source
To see the full content, share this page by clicking one of the buttons below |
When I run I got syntax error said option.? session so what should I do. I am using nodejs version 12 and mongodb 7.0
every time I try to launch the server I always get this error and yet mongodb is launched correctly
PS D:angular1mongotestserver> node index.js
Server is running
D:angular1mongotestservernode_modulesmongooselibconnection.js:809
err = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
at _handleConnectionErrors (D:angular1mongotestservernode_modulesmongooselibconnection.js:809:11)
at NativeConnection.openUri (D:angular1mongotestservernode_modulesmongooselibconnection.js:784:11) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) {
'localhost:27017' => ServerDescription {
address: 'localhost:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 608858250,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (D:angular1mongotestservernode_modulesmongodblibcmapconnect.js:379:20)
at Socket.<anonymous> (D:angular1mongotestservernode_modulesmongodblibcmapconnect.js:285:22)
at Object.onceWrapper (node:events:632:26)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[Symbol(errorLabels)]: Set(1) { 'ResetPool' },
[cause]: Error: connect ECONNREFUSED ::1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 27017
}
},
topologyVersion: null,
setName: null,
setVersion: null,
electionId: null,
logicalSessionTimeoutMinutes: null,
primary: null,
me: null,
'$clusterTime': null
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
Node.js v18.18.0
Great video but if you are getting the "Cannot Get error" after running node, I solved it by removing the getUsers from line 14. function since we are not using routing, simply replace it with '/' should get the code working.
how do i connect with mongoclient ?
hi brother, the server is running, butt not showing in the browser error and says "This site can’t be reached" "localhost refused to connect." my url is http://localhost:3001/getusers
Thanks!
Man, I was stuck and you set me free…now I can go on with my course!! Thanks a Lot!
unbale to connect…tried so many times
hello @yousaf
why are you using required express? we can use import express too?
How do you just like that you use "/getUsers"in. The app.get
Cannot get error is coming
thanks it helped me
It is unable to connect even I followed every steps.
thnx….u helped me to connect
Thank you, I've been trying to connect mongodb locally and I was getting issues connecting, not knowing the url port should not be localhost
A1
❤🎉❤
❤🎉❤