CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud
343 stars 193 forks source link

problem in connecting with mongodb #38

Open rjunaid1807 opened 1 year ago

rjunaid1807 commented 1 year ago

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;`

vinaysharma9600 commented 1 year ago

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

dhillonsahil commented 1 year ago

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