skip to Main Content

Javascript – MongoDB ECCONREFUSED when connecting to MongoDB Compass

I am trying to learn Node.JS from scratch. I am trying to connect index.js to MongoDB compass when I get the error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 at _handleConnectionErrors (/mnt/c/Users/user/Desktop/Programming/website/learningNode/mongoose/node_modules/mongoose/lib/connection.js:897:11) at NativeConnection.openUri (/mnt/c/Users/user/Desktop/Programming/website/learningNode/mongoose/node_modules/mongoose/lib/connection.js:848:11) { reason: TopologyDescription { type: 'Unknown', servers: Map(1)…

VIEW QUESTION

ReactJS, NodeJS, MongoDB, Backend

in index.js, const express = require("express") const mongoose = require("mongoose") const cors = require("cors") const CustomerModel = require('./models/Customer') const app = express() app.use(express.json()) app.use(cors()) mongoose.connect("mongodb://localhost:27017/customer") app.post("/login", (req, res) => { const {email, password} = req.body CustomerModel.findOne({email: email}) .then(user => {…

VIEW QUESTION
Back To Top
Search