CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem in connecting with mongodb

rjunaid1807 opened this issue · comments

I have been trying to connect MongoDB to my project exactly by following the videos but it doesn't work. following is my db.js file. Please look through it for errors. I doubt if there is anything wrong with the format of the connection string. Anyone? Please guide!

`const mongoose = require('mongoose');
const mongoURI = "mongodb://localhost:27017";

const connectToMongo = ()=> {
mongoose.connect(mongoURI, ()=> {
console.log("Connected to Mongo successfully");
})
}
module.exports = connectToMongo;`

Bro You should start the Mongodb server go to mongodb compass and click on save and connect if you got the error in starting mongodb server then go to windows search bar and search services and find MongoDb and the right clck on it and start
after again come to mongodb compass and click on save and connect . I Think your problem will be solve

commented

Use this :-
const mongoURI = "mongodb://127.0.0.1:27017";