Christian Potdevin
Christian Potdevin

Reputation: 111

mongodump results in Failed: can't create session: could not connect to server: connection() : dial tcp: i/o timeout

I am trying to backup a database from MongoDB Atlas.

When running the following mongodump command (with missing information of course):

mongodump --uri mongodb+srv://<USERNAME>:<PASSWORD>@<STUFF>.mongodb.net/<DATABASE> 

I receive the following response:

Failed: can't create session: could not connect to server: connection() : dial tcp: i/o timeout

I have tried this command on another computers and it works fine so I'm pretty sure the error is not on the server end and has something to do with my computer (although I am able to mongodump a local database). I've also tried to mongodump other MongoDB Atlas databases on other accounts but receive same response.

mongodump was installed through homebrew following the MongoDB installation documentation of mongodb-community. I've tried completely removing all mongodb related files on my system (including mongodb-database-tools) and reinstalling mongodb-community. Locally, I am able to connect to the database through the javascript mongodb nodejs driver.

When I run mongodump --version I receive:

mongodump version: 100.3.1
git version: 32632b931f9c41d8314b75ecc88e551b012b1e30
Go version: go1.15.8
   os: darwin
   arch: amd64
   compiler: gc

I am running macOS Catalina version 10.15.7 on a Mid 2012 Retina MacBook Pro.

Update

I've now tried the mongodump command while using a VPN service and it works.

Update 2

After 24 hours the mongodump command started working again. I believe it was a problem with my internet provider's firewall (or other) not allowing the command to connect to the MongoDB Atlas server.

Upvotes: 5

Views: 3398

Answers (1)

Rohit Swami
Rohit Swami

Reputation: 316

The right solution is to whitelist your current IP address in Network Access tab of a cluster. Steps:

  1. Go to Network Access tab
  2. Click + ADD IP ADDRESS button
  3. Enter your current IP address in Access List Entry field.
  4. Confirm

Upvotes: 0

Related Questions