Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't connect to mongoDB atlas #6

Open
tinkerFAUJ opened this issue Nov 3, 2019 · 4 comments
Open

can't connect to mongoDB atlas #6

tinkerFAUJ opened this issue Nov 3, 2019 · 4 comments

Comments

@tinkerFAUJ
Copy link

hi
thanks a lot for a great tutorial. I am new to nodejs and the whole mern stack.
I have executed the code as instructed but the connection to mongoDB atlas is not working.
The confirmation string about the successful connection is displayed on the console.
also the mongoDb cluster dashboard does not show any connections

@utshomomen
Copy link

I have the same problem.

@dacicus75
Copy link

I added mongodb dependency to backend, and also used whole driver for connection

@nabarunhalder
Copy link

Can you please explain the process in a elaborated way, I'm having the same issue. Thanks.

@dacicus75
Copy link

Added mongodb dependency to package.json file for backend.

db connection in server.js

const uri = process.env.ATLAS_URI;
mongoose.connect(uri, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true }
);
const connection = mongoose.connection;
connection.once('open', () => {
console.log("MongoDB database connection established successfully");
})

const tasksRouter = require('./routes/tasks');
const usersRouter = require('./routes/users');

app.use('/tasks', tasksRouter);
app.use('/users', usersRouter);

app.listen(port, () => {
console.log(Server is running on port: ${port});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants