11

I'm migrating mLab from Heroku to MongoDB Atlas. As one of steps I want to check if there is a connectivity to newly created cluster. I'm used Robo3T (formerly Robomongo) for Heroku mLab instances. But it doesn't work with Atlas. I'm getting following error when creating connection from URL:

Cannot connect to replica set "SampleProject"[cluster-abcd12ef-shard-00-00.a0b1c.mongodb.net:27017]. 
Set's primary is unreachable.

Reason:
Failed to initialize MongoWorker. Reason: connect failed

Tried to adjust settings, but everything looks correct there, like for Heroku, the only host and port are different.

Also looked on similar questions and on GitHub isssues but nothing helped.

wowkin2
  • 5,895
  • 5
  • 23
  • 66

6 Answers6

32

First of all, check if you are using latest Robo3T. MongoDB Atlas uses mongodb+srv:// protocol, that was not supported some time before.

After that please go by following check-list:

  • Use import From SRV by copy-pasting URL from MongoDB Atlas;
  • MongoDB Atlas is using Replica Sets even for free Sandbox (Atlas M0) accounts. So during creation ensure that you used that type;
  • Fill or check all cluster members;
  • Set Name should be set.

important differences on Authentication tab:

  • Database should be admin not like database name (used on Heroku),
  • Auth Mechanism should be SCRAM-SHA-1
  • Check Manually specify visible databases and type there admin,<you database name from Heroku>

on TLS tab:

  • Check Use TLS protocol
  • Authentication method - Self-signed Certificate

Now it should work.

P.S. Previously, I also had problems with having database same like on Heroku with same db-name and user-name, also I thought that Auth Mechanism should be MONGODB-CR. But that didn't work.

P.P.S. If you don't see Manually specify visible databases - then please check if you have the latest version (1.4.+) of Robo3T (previously known as Robomongo)

wowkin2
  • 5,895
  • 5
  • 23
  • 66
  • Just downloaded on Mac & Windows. Mac works and Windoes does not. Confirmed all inputs/form fields match the "answer". Windows Build is Robo 3T 1.4.3 (Build 48f7dfde - 3/2021). Sometimes I get the error as stated in orignal thread other times the app just crashes unexpectedly. – Greg Mar 12 '21 at 20:06
  • @Greg, worked for me on 1.4.1. And for later versions I see [issues on GitHub](https://github.com/Studio3T/robomongo/issues). You can try to also use 1.4.1. BTW, where your MongoDB is hosting? – wowkin2 Apr 05 '21 at 09:07
  • 1
    Amazing. Details are just perfect. Didn't find it anywhere else. Thank you somuch – DroidBoyJr Sep 25 '21 at 20:50
  • 1
    After "import from URI" i had to go and set the certificate to "Self-signed Certificate" that was what did the trick for me! – kroe Jan 09 '23 at 07:49
9

If anyone getting this error while using Robo3T version 1.4.4, we can resolve this issue by update robo3t.json file (enable logs and you can see where this file localed)

By enable Logs, you will see where settings saved via message starts with Info: Settings saved to: {robo3t.json_path}

  • Paste your URI as normal, then click From URI as normal, then Save.
  • Close Robo3T (important)
  • Open robo3t.json file using some text editor.
  • Inside connections scope, lookup your connection just created from step above, find allowInvalidCertificates property inside ssl object, change value from false to true then save the file
  • Open Robo3T then connect to the connection, it should connect normally
  • 1
    Thanks, bro! You saved a few hours of work for me – Victor Fazer Dec 05 '21 at 13:44
  • For those who wonder how to enable logs, in the top left corner, near `File` there is `View`. Click on that and you can find a checkbox for logs. Enable that checkbox and you will find a dialogue box opens at the bottom of applications with logs. Scroll up in that logs and you can find the path to `robo3T.json`. – sebin vincent Mar 02 '22 at 07:52
  • We can also use `Ctrl+L` to open logs. – sebin vincent Mar 02 '22 at 07:55
5

Make sure you have whitelisted your IP address on mongodb cloud portal under Network Access.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Pankaj Shinde
  • 73
  • 1
  • 9
  • using DigitalOcean Mongodb cluster manged service, this seems crucial step + specify a 'self-signed ' certificate type on TLS tab without the need to – Samih A Feb 19 '22 at 18:07
1

Check your username and password!

tl;dr

It seems Robo 3T 1.4.3 returns the Cannot connect to replica set... Set's primary is unreachable error also for authentication errors. Double check your user credentials.

Details

In the past, all the above excellent answers have helped me resolve this error message. However, recently I encountered an Atlas cluster that seemed immune to all workarounds. I finally gave up and tried with the "official" MongoDB Compass client that Atlas promotes. This client also returned an error, but a different and far more useful one:

bad auth : Authentication failed.

Suspecting an incorrect password, I generated a new password for the user in Atlas and updated it in Robo 3T. After this Robo successfully connected to the DB.

Boaz
  • 19,892
  • 8
  • 62
  • 70
1

After doing import "From URI" i had to go TLS -> "Authentication Method" and select "Self-signed Certificate".

I didn't have the same problem when connecting from the MongoDB extension on VSCode.

kroe
  • 1,116
  • 3
  • 11
  • 23
0

For me I needed to go into the Edit section of the Connection:

enter image description here

Then under the Authentication tab:

enter image description here

Paste my password into the password input:

password input

The passwords in my json files were encrypted, so I needed the unencrypted password directly from Atlas

JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71