MongooseServerSelectionError: Failed to connect to 127.0.0.1:27017
at NativeConnection.Connection.openUri (/mnt/d/Ecommerce/node_modules/mongoose/lib/connection.js:802:32)
at /mnt/d/Ecommerce/node_modules/mongoose/lib/index.js:341:10
at /mnt/d/Ecommerce/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
at new Promise (<anonymous>)
at promiseOrCallback (/mnt/d/Ecommerce/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/mnt/d/Ecommerce/node_modules/mongoose/lib/index.js:1141:10)
at Mongoose.connect (/mnt/d/Ecommerce/node_modules/mongoose/lib/index.js:340:20)
at connectDatabase (/mnt/d/Ecommerce/backend/config/database.js:4:14)
at Object.<anonymous> (/mnt/d/Ecommerce/backend/server.js:11:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
}
}
I have also tried using 'mongod'.
I have made sure to create a folder in my C:\data\db directory.
Additionally, I have used the IP address 127.0.0.1 instead of 'localhost'.
Despite trying numerous solutions, I am still encountering this error. How can I troubleshoot and fix it?