Unable to connect to Atlas

Expected behavior

Connect to my Mongo DB Atlas cluster when creating new Forest project

Actual behavior

I’m getting an error when running the lumber-cli command to create my forest project

Failure Logs

> Connecting to your database
> Cannot connect to the database due to the following error:
> MongoParseError: URI does not have hostname, domain name and tld

Context

I read another ticket with a similar problem, but in that case, the user said he/she was able to fix it by adding the SRV option in the advanced options tab. I checked it and set the authSource to admin and my DB username with no luck. I’m using the cluster link for mongo shell connections, as it’s the only one that does not include the username and password in the actual link. I’m not sure what type of link to use in order to connect my atlas cluster to Forest.

Please provide any relevant information about your setup.

  • Package Version: 3.6.5
  • Express Version:
  • Sequelize Version:
  • Database Dialect: MongoDB
  • Database Version: 4.2.8
  • Project Name: Tranki

Hi @Henry_O,

The MongoDB URI needs to match this format mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]], and should be well generated if you use the onboarding screen when creating your project.

If I understand your problem correctly, you don’t want to connect using a user/password?

No, I don’t mind the user / password. I was just a bit confused because the onboarding screen is asking for the host, user and password, all separated. When I go to the my Atlas cluster and click “Connect”, I get a connection string just like the one you wrote (everything mixed up in the same string).

I was a bit confused because I didn’t want to specify the user / password twice, as I though that would be a problem. I will try by putting the entire link and see how it goes.

The onboarding screen is in fact here to ensure your connection string is well formatted, and mostly here to create the lumber generate command that will create your project.

You should still be able to replace it in the lumber generate command in case you made a mistake, or just go back to the screen where each parameters is set individually.

All the onboarding screen are here to ensure a smooth project creation, but if you are still facing any issue, don’t hesitate to ask.

Thanks!

I got it working this morning. I just had to double check the generated link and make very small changes (basically some values were getting duplicated). I also had to activate SSL and set auth source to my DB’s user name in the advanced options sections.

Since I’m on the free tier of atlas, my models weren’t imported automatically. I just had to define them in the models folder and everything is working great.

Cheers!

1 Like