Error: queryTxt EREFUSED

Error: queryTxt EREFUSED
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:275:17) {
  errno: undefined,
  code: 'EREFUSED',
  syscall: 'queryTxt',
  hostname: ''

Hi @sourabh_patole,

Welcome to the MongoDB Community!

The queryTxt error message generally indicates the DNS in use by the client attempting to connect is unable to resolve the TXT record.

For troubleshooting this, you can attempt either of the following:

  1. Use another DNS server such as (Google’s public DNS) to see if the issue is resolved
  2. Connect using the Standard Connection String format as noted in the following documentation.
  3. Attempt to connect from a different network connection

Please take note that it is recommended to use the DNS seed list connection string as the DNS can construct the list of the available servers allowing more flexibility of deployment and the ability to change the servers in rotation without reconfiguring clients.

However, in saying so, the above three methods should assist with initial connectivity troubleshooting related to the queryTxt error provided.

Additionally, I would recommend reviewing the Troubleshoot Connection Issues documentation and verifying some configurations, such as adding the client’s IP (or IP ranges) to the Network Access List. You may also find the following blog post regarding tips for atlas connectivity useful.

If you’re still encountering further issues whilst connecting after attempting the above methods, please provide any error messages received

Best regards,