I am using ArchCraft. Recently I installed MongoDB on my OS and when I type show dbs it gives me the exact result. But when I run my backend project using npm start it says database connection failed. Then I check my MongoDB Compass but there was not any database created.
//database connection
mongoose
.connect(process.env.DATABASE_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Database Connection Successfull");
})
.catch(() => {
console.log("Database Connection Failed");
});
here is my database connection source code. here I am using dotenv. In this file I write this code DATABASE_URL = mongodb://localhost:27017/MEVN_STACK
, When I use Ubuntu it works perfectly but now it isn’t working. Please help me to find out the reason.