How to check if my ISP is blocking port 27017

…and if yes, what should I do?

I am learning how to use mongodump to export data from a collection. I tried two ways:

  1. 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|

  1. 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?

Hi @nisajthani,

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

Hope this helps.

Best Regards,
Jason

1 Like

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?

1 Like

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?

Thanks for marking that as the solution in regards to the port testing question.

Are you able to try the following:

mongodump --uri "mongodb://USERNAME:PASSWORD@sandbox-shard-00-00.4izby.mongodb.net:27017,sandbox-shard-00-01.4izby.mongodb.net:27017,sandbox-shard-00-02.4izby.mongodb.net:27017/?replicaSet=REPLICASETNAME&authSource=admin" --ssl --db DBNAME

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:

Also, you may experience this error if the client is running Ubuntu 18.04 as noted on the documentation:

cannot unmarshal DNS message

If you are still getting any errors, please send the full command run as well as the error output. Please redact any credentials before doing so.

Hope this helps,
Jason

1 Like

Thank you. Your suggestion worked! Yes, my client is indeed an Ubuntu 18.04. I will read the documentation more thoroughly after this.

1 Like

Glad to hear it worked :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.