MongoDB refuses connection

I am trying to build a MERN stack application. I am using MongoDB Atlas. I have a collection named test under which I have a database called test also. Here is my URL:

URL: mongodb+srv://

Password is ***** for just example.

I put as test without any tags “<>”.

When I try to establish connection, it says connection failed. May I know my error?

Most video tutorials show the MongoDB URL with a supposedly pre-made database name called “test”, but I noticed nowadays one has to put it. So I just created one.

Please guide me. Thanks in Advance.

I am referring to the video by Beau Carnes.

Hello @saditsnigdho.

Welcome to FCC.
Are you sure you are using the correct password. For example one of my connection URLs looks like:


I don’t see the <password> and <dbname> sections in your URL. Try:


Take note of the password field.

Did you open the connections using

It be good if you include the full error, or a screenshot.

I copied it but I guess it is not being shown as I don’t know the correct syntax for posting such content. Anyway, my URL looks like your one. As of now, I have a test and collection named “test”. Now I guess you know. Thanks.

What do you mean by that statement? What is the name of the:

  • cluster
  • the database
  • and the collection?
    From the URL, I assume the name of your cluster is mern, what about the database and the collection? How have you named them?

When you enter a code block into a forum post, precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor ( </> ) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Sure. I will be posting it. Thanks.

Cluster is mern. Collection and Database both is test. Still it refuses connection when I try with npm start and check console. However when I try with node server.js it says connection established however my get and post request failed. I guess I have a problem connecting with the database.

Include the full error, preferably a screenshot.

As suggested by @Minsky you need to include the full error message and the code you are using to connect and make a POST/GET request to the database. It will be easier to help.