title: How to clone/copy a database in Azure Cosmos DB
body: <p>How do I clone a database in Azure Cosmos DB to a <code>mongod</code> running on localhost:27001?</p>
  
  <p>I've tried the following, but I can't get it working:</p>
  
  <pre><code>db.cloneDatabase("mycosmosdb:mypassword@username.documents.azure.com:10255/MyDatabase?ssl=true&amp;replicaSet=globaldb")
  </code></pre>
  
  <p>This returns the following when running the command from my local machine where <code>mongod</code> is running :</p>
  
  <pre><code>{
      "clonedColls" : [ ],
      "ok" : 0,
      "errmsg" : "connect failed to replica set mycosmosdb:mypassword@username.documents.azure.com:10255/Mydatabase?ssl=true&amp;replicaSet=globaldb:27017",
      "code" : 6,
      "codeName" : "HostUnreachable"
  }
  </code></pre>
  
  <p>Trying this variant also fails:</p>
  
  <pre><code>db.copyDatabase("NameOfAzureDB", "NameOfLocalDB", "username.documents.azure.com:10255", "username", "password")
  
  {
      "ok" : 0,
      "errmsg" : "couldn't connect to server username.documents.azure.com:27017, connection attempt failed"
  }
  </code></pre>