Keep Failing to connect to my Cosmos DB, saying timeout

Isaac 10 Reputation points
2025-10-08T16:29:27.9366667+00:00

I have an Azure Cosmos DB for MongoDB (vCore) with M20 tier, 2 vCores, 4 GiB RAM. It works fine previously, and I didn't change any settings after creation. Just started from yesterday, I keep failing to connect to the database with timeouts. I checked the metrics and all the CPU, memory, storage usages look fine and stable.

User's image

Also, I'm pretty sure it's not the network policy because I opened 0.0.0.0-255.255.255.255 since creation and it works fine previously. I didn't change any policies before the issue happened.
User's image

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Swapnesh Panchal 750 Reputation points Microsoft External Staff Moderator
    2025-10-08T17:14:23.7033333+00:00

    Hi Isaac ,
    Thank you for reaching out on Microsoft Q&A forum.
    Cluster looks healthy and your firewall is open, so sudden “timeout” on cosmos db for mongodb (vCore) is almost always dns or something in the outbound path (vpn/proxy/ipv6).

    1. check access mode
      • public: you should reach the public hostname over the internet
      • private endpoint: dns must return the private ip and the private dns zone must be linked to your vnet
    2. use the right port
      • mongodb vcore listens on 27017 (tls)
    3. test tcp from your machine
      • windows: Test-NetConnection -Port 27017
      • linux/mac: nc -vz 27017
      • if this fails, something on the path blocks it
    4. bypass srv
      • try a direct string: mongodb://:@:27017/?tls=true&authSource=admin&directConnection=true
      • if this works but mongodb+srv fails, it’s a dns/srv issue
    5. check dns
      • nslookup → expect public ip (public) or private ip (private link)
      • if using srv: nslookup -type=SRV _mongodb._tcp.
      • if you see ipv6 (AAAA) answers, disable ipv6 or force ipv4 and retry
      • flush dns cache and try again
    6. check tls handshake
      • openssl s_client -connect :27017 -tls1_2 -servername -brief
      • hang/fail usually means a proxy or tls inspection
    7. remove middleboxes
      • disconnect vpn and proxy; try a mobile hotspot
      • ensure local firewall allows outbound 27017
      • recheck your current public ip if you rely on allowlists
    8. control test from azure
      • create a small azure vm, install mongosh, connect with the same string
      • works from vm but not from your place → your egress is the problem
      • fails from both → likely private dns link, nsg/udr, or rare regional issue
    9. update client
      • use the latest mongosh/driver, tls 1.2+
      • set connectTimeoutMS to 10000–20000
      • enable tcp keep-alive if idle sockets drop later

    Refer to this resource for complete details:


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.