MongoDB Compass: Persistent "queryTxt ECONNREFUSED" error when connecting to Azure cluster

Homelab Platypus 0 Reputation points
2026-09-04T17:51:13.0733333+00:00

Hi everyone,

In my Azure project, I have a 'Azure DocumentDB (with MongoDB compatibility)' resource. About a month ago, I was able to use MongoDB Compass (ver 1.50) on my laptop to successfully connect to the MongoDB cluster. After not using Compass for about a month (maybe two?), I went to use Compass again today. Now I consistently get this error:

queryTxt ECONNREFUSED my-cluster.global.mongocluster.cosmos.azure.com

FYI, the connection string I get off the Azure Portal is this:

mongodb+srv://me:******@my-cluster.global.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000

I've done all of the following to troubleshoot:

  • In Compass: Replaced the connection string multiple times. Yes, I'm certain the password is correct.
  • Enabled "permit all" in MongoDB firewall rules
  • DNS testing:
    • SRV lookup succeeds using nslookup
    • Node resolveSrv succeeds
    • Node resolveTxt returns normal ENODATA
    • TCP port 10260 succeeds
    • Pointed to multiple DNS servers
  • Tried connecting with both MongoDB Compass and mongosh

The DNS testing always passed. However, every time I tried to connect to the MongoDB cluster itself, always the same error: "queryTxt ECONNREFUSED"

My research suggests this is a DNS resolution issue, but I can't replicate that issue when testing DNS alone.

Anyone else seen this?

Azure DocumentDB
Azure DocumentDB

A scalable, fully managed NoSQL database for JSON documents with fast queries and automatic indexing

0 comments No comments

1 answer

Sort by: Most helpful
  1. Abdul Waqas 345 Reputation points
    2026-09-04T18:07:52.2166667+00:00

    Hi,

    Based on the troubleshooting already completed, DNS does not appear to be the main issue. Since the SRV, TXT, DNS resolution, and TCP connectivity to port 10260 are working, I would focus on the cluster’s networking and connection settings.

    I suggest checking:

    Azure Portal → Cosmos DB for MongoDB vCore → Networking and confirm the public access/firewall rules allow the laptop’s public IP.

    Confirm the cluster is in a Ready/healthy state and there have been no recent networking or private endpoint changes.

    In MongoDB Compass, use the exact connection string provided by Azure Portal and make sure no conflicting Replica Set Name is configured.

    Test the same connection string using mongosh from the same laptop. If it fails with the same queryTxt ECONNREFUSED error, the issue is likely not specific to Compass.

    If DNS and TCP/10260 are working but mongosh also fails, I would focus on the Azure networking/firewall configuration and then consider a possible service-side issue rather than continuing with DNS troubleshooting.

    Microsoft documents MongoDB vCore connectivity over port 10260 and recommends using the connection details provided by Azure.

    **Microsoft Learn references:

    **https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/connect-using-compass⁠

    https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall⁠

    https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/connect-account⁠

    Was this answer helpful?


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.