Importing Data (error parsing uri)

Hi, I visited all topics that had related errors, after some research time I still can not solve the problem.

Command executed:

my-pc@my-pc:~/Documents/M220J-MongoDB-for-Java-Developers/mflix-java/mflix$ mongorestore --drop --gzip --uri mongodb+srv:// data


error parsing command line options: error parsing uri (mongodb+srv:// lookup on cannot unmarshal DNS message

I’m using Linux Mint 19.1

mongorestore version: r4.0.8
git version: 9b00696ed75f65e1ebc8d635593bed79b290cfbb
Go version: go1.11.6
os: linux
arch: amd64
compiler: gc
OpenSSL version: OpenSSL 1.1.0g 2 Nov 2017

In the topic below the solution was to install version 3.6.12

The same happend to me an was because the connection string I didnt put the user and the password, the full line should be:
note: change …mflix-xxxxx… with your real connection.

Hope it help. Teo

I am trying to restore data via linux shell, I still can not solve this problem.

Any pointers? I am also facing the same issue. I can connect to the cluster using the ‘mongo’ command. But the ‘mongorestore’ command fails with error ‘cannot unmarshal DNS message’.

Exactly, my problem is the same, I can also connect to the mongo, but mongorestore does not work.

@flp_correa @dbsaku,

can you share your MongoDB URI?


Alternatively, i tried by separating out all the options in mongorestore:

mongorestore --drop --gzip -u m220student -p m220password -h data

which gave a more indicative error message (again referring to possible DNS issue):

Failed: error connecting to db server: no reachable servers

Does this light any bulbs?

This StackOverflow post talks something about replica sets in a scenario similar to that discussed here.

There was an answer to run rs.initiate from the server, but admin does not have sufficient rights to issue the command.

@Norberto, any new ideas?


I was able to restore the data only in the localhost environment

Hi @dbsaku,

I managed to load the dataset for you. This is the command that I’ve run:

mongorestore --gzip --drop  --uri "mongodb+srv://" -d mflix mflix

You missing the quotes on your uri in your first attempt.

In this case, the server is unreachable because you are using the SRV address instead of the actual MongoDB cluster instance.
Running the command that I’ve shared fixes it for you.
Please do try it again from your end to discard any other connectivity issues.


Hi @Norberto,

Thanks for loading the dataset for me.

I tried the command you have issued (I had not missed the quote characters before). But no luck creating the database; the same error is reported. In fact, it is trying to resolve the DNS address.

$ mongorestore --gzip --drop  --uri 'mongodb+srv://' -d mflix mflix
2019-04-14T15:36:34.802+0530	error parsing command line options: error parsing uri (mongodb+srv:// lookup on cannot unmarshal DNS message
2019-04-14T15:36:34.802+0530	try 'mongorestore --help' for more information

Also, mongorestore just hangs if I remove the “+srv” part of the uri.

I wonder if the mongorestore version is incompatible with the cluster version. My version information is:

mongorestore version: r4.0.7-13-g941a6dc4a7
git version: 941a6dc4a709ea3014786c3c5effe1f92a4acc23
Go version: go1.11.4
   os: linux
   arch: amd64
   compiler: gc
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017


If you use Ubuntu like me. It will not work. But the same query works on Windows fine.

Interesting. What’s the difference?

I failed to import data on Ubuntu 18.04 according to m220 course instruction.
But success to import according to Mongo Atlas instruction.
Click on mflix > Command Line Tools > Binary Import and Export Tools

Great! This worked for me. Thanks @vort.