[MongoExport] cannot unmarshal DNS message

Hello,
I’ve followed the Tutorial up to Chapter 2.

I’m trying to mongoexport a DB collection via my CLI. But, I encountered the below error. How may I resolve it?

mongoexport --uri "mongodb+srv://{USER}{PASSWORD}@sandbox.bfryh.mongodb.net/sample_airbnb" --collection listingsAndReviews --out listings.json
2021-06-11T16:46:42.552-0400	error parsing command line options: error parsing uri (mongodb+srv://m001-student:m001-mongodb-basics@sandbox.bfryh.mongodb.net/sample_airbnb): 
lookup sandbox.bfryh.mongodb.net on 10.13.8.130:53: cannot unmarshal DNS message

My MongoDB version is:
MongoDB shell version v4.0.22
git version: 1741806fb46c161a1d42870f6e98f5100d196315
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64

And my MongoExport is:
mongoexport version: r4.0.22
git version: 1741806fb46c161a1d42870f6e98f5100d196315
Go version: go1.11.13
os: darwin
arch: amd64
compiler: gc

Can you connect to your cluster with SRV string?
Use the command generated in your Atlas
If SRV string does not work there is a long form of connect string
Try without quotes

Thank you for your suggestion.

Strangely, I can connect to my cluster, I got the message below.
Executed command below
mongo "mongodb+srv://m001-student:m001-mongodb-basics@sandbox.bfryh.mongodb.net/sample_airbnb"

Got the results below

MongoDB shell version v4.0.22
connecting to: mongodb://sandbox-shard-00-00.bfryh.mongodb.net.:27017,sandbox-shard-00-01.bfryh.mongodb.net.:27017,sandbox-shard-00-02.bfryh.mongodb.net.:27017/sample_airbnb?authSource=admin&gssapiServiceName=mongodb&replicaSet=atlas-vya9dp-shard-0&ssl=true
2021-06-14T09:01:46.636-0400 I NETWORK  [js] Starting new replica set monitor for atlas-vya9dp-shard-0/sandbox-shard-00-00.bfryh.mongodb.net.:27017,sandbox-shard-00-01.bfryh.mongodb.net.:27017,sandbox-shard-00-02.bfryh.mongodb.net.:27017
2021-06-14T09:01:46.935-0400 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-00.bfryh.mongodb.net.:27017 (1 connections now open to sandbox-shard-00-00.bfryh.mongodb.net.:27017 with a 5 second timeout)
2021-06-14T09:01:46.941-0400 I NETWORK  [js] Successfully connected to sandbox-shard-00-01.bfryh.mongodb.net.:27017 (1 connections now open to sandbox-shard-00-01.bfryh.mongodb.net.:27017 with a 5 second timeout)
2021-06-14T09:01:46.992-0400 I NETWORK  [js] changing hosts to atlas-vya9dp-shard-0/sandbox-shard-00-00.bfryh.mongodb.net:27017,sandbox-shard-00-01.bfryh.mongodb.net:27017,sandbox-shard-00-02.bfryh.mongodb.net:27017 from atlas-vya9dp-shard-0/sandbox-shard-00-00.bfryh.mongodb.net.:27017,sandbox-shard-00-01.bfryh.mongodb.net.:27017,sandbox-shard-00-02.bfryh.mongodb.net.:27017
2021-06-14T09:01:47.213-0400 I NETWORK  [js] Successfully connected to sandbox-shard-00-00.bfryh.mongodb.net:27017 (1 connections now open to sandbox-shard-00-00.bfryh.mongodb.net:27017 with a 5 second timeout)
2021-06-14T09:01:47.226-0400 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to sandbox-shard-00-01.bfryh.mongodb.net:27017 (1 connections now open to sandbox-shard-00-01.bfryh.mongodb.net:27017 with a 5 second timeout)
2021-06-14T09:01:47.587-0400 I NETWORK  [js] Successfully connected to sandbox-shard-00-02.bfryh.mongodb.net:27017 (1 connections now open to sandbox-shard-00-02.bfryh.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { "id" : UUID("77a476e2-b421-47a1-98b3-a79270355d78") }
MongoDB server version: 4.4.6
WARNING: shell and server versions do not match
MongoDB Enterprise atlas-vya9dp-shard-0:PRIMARY>

You are able to connect to your cluster with SRV string but mongoexport is failing with SRV
It could be due to incompatible DNS server or your ISP blocking
Did you try from another network/location
or
use long form of string with --host option
You can get the command from your Atlas from command line tools

2 Likes

Thank you @Ramachandra_Tummala , you’re a genius. It worked.

Although I tried it from the same location, the issue was that mongoexport doesn’t work when I’ve my VPN enabled.

Also, that’s good advice about using Atlas’s CLI Tools tab. Makes it much easier.

Thank you again!

1 Like

Thanks, @Ramachandra_Tummala for your efforts and helping out @Joshua_Cadavez :sparkles:

We are glad @Joshua_Cadavez, that your issue has been resolved. :+1:
In case of any further issues, please feel free to reach out.

Thank you,
Kushagra

2 Likes