I am learning how to use mongodump to export data from a collection. I tried two ways:
The first way mongodump --uri mongodb+srv://<USERNAME>:<PASSWORD>@sandbox.4izby.mongodb.net/sample_mflix
I got the following error:
|2021-04-06T13:54:17.235+0800|error parsing command line options: error parsing uri: lookup sandbox.4izby.mongodb.net on 127.0.0.53:53: cannot unmarshal DNS message|
|—|—|
|2021-04-06T13:54:17.235+0800|try ‘mongodump --help’ for more information|
The second way mongodump --host="Sandbox/sandbox-shard-00-00.4izby.mongodb.net:27017,sandbox-shard-00-01.4izby.mongodb.net:27017,sandbox-shard-00-02.4izby.mongodb.net:27017" --db="sample_mflix" --collection="movies"
I got the following error: 2021-04-06T13:38:46.923+0800 Failed: can't create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: sandbox-shard-00-00.4izby.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(sandbox-shard-00-00.4izby.mongodb.net:27017[-181]) incomplete read of message header: EOF }, { Addr: sandbox-shard-00-01.4izby.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(sandbox-shard-00-01.4izby.mongodb.net:27017[-182]) incomplete read of message header: EOF }, { Addr: sandbox-shard-00-02.4izby.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(sandbox-shard-00-02.4izby.mongodb.net:27017[-180]) incomplete read of message header: EOF }, ] }
I looked around the forum and found that some people encountered similar problems due to their ISP blocking port 27017. How do I check if that is the case?
Thanks for sharing the commands being used and the errors returned.
I looked around the forum and found that some people encountered similar problems due to their ISP blocking port 2701. How do I check if that is the case?
I assume meant 27017 here as your commands used state port 27017. However, please correct me if I am wrong.
One way can be to use the http://portquiz.net:27017 website. From the client attempting to connect to the Atlas cluster, you can either visit the above website and if it loads it would indicate that you can connect to port 27017.
Alternatively, you can run:
curl http://portquiz.net:27017
If successful, you should receive response similar to the following:
Port 27017 test successful!
Your IP: 172.12.34.123
I have used the curl command and have confirmed my ISP is not blocking the port number. Unfortunately, that means I once again have no clue why mongodump isn’t working.
But since main the question has been answered, I’ll mark the topic as ‘Solved’. Is it a good idea if I post my problem in new topic?
You’ll need to replace USERNAME, PASSWORD, REPLICASETNAME and optionally DBNAME.
Atlas requires TLS/SSL connections for all Atlas clusters which is why you may have received the connection failure error through the second method.
I can see you have used Sandbox as your replicaSet name when performing the mongodump via your second method. To get the correct replicaSet name for the Atlas cluster to be used in my above example, you can go through the connect modal in Atlas for your cluster and choose mongoshell, from there you can change the version to 3.4 and you will find the replicaSet value as shown in the example below: