Skip to content

Bug Report #1320

Description

@ThinkYuvraj

Bug Report

Current Behavior

When attempting to connect to a MongoDB Atlas cluster using the MongoDB for VS Code extension, the connection fails with the following error:

Unable to connect: querySrv ECONNREFUSED _mongodb._tcp.cluster0.lwaglnx.mongodb.net

The exact same connection string works successfully in mongosh. I am able to connect to my MongoDB Atlas M0 cluster without any issues using mongosh, but the VS Code MongoDB extension consistently fails with the error above.

Code/Gist

Connection string (password hidden):

mongodb+srv://thinkyuvraj_db_user:********@cluster0.lwaglnx.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0

Expected Behavior/Code

The MongoDB for VS Code extension should successfully connect to the MongoDB Atlas cluster using the same connection string that works in mongosh.

Steps to Reproduce

  1. Install the MongoDB for VS Code extension.
  2. Open VS Code.
  3. Click "Add Connection".
  4. Paste the MongoDB Atlas SRV connection string.
  5. Click Connect.
  6. The extension displays:
    Unable to connect: querySrv ECONNREFUSED _mongodb._tcp.cluster0.lwaglnx.mongodb.net
    

Troubleshooting Performed

  • Verified internet connection (ping google.com successful).
  • Verified DNS resolution (nslookup cluster0.lwaglnx.mongodb.net successful).
  • MongoDB Atlas cluster is running (M0 Free Tier).
  • Added my IP address in Atlas Network Access.
  • Verified database user credentials.
  • Reset the database user password.
  • Successfully connected using mongosh with the exact same connection string.
  • Deleted and recreated the VS Code connection.
  • Restarted VS Code.

Environment

  • Operating System: Windows 11
  • MongoDB Atlas: M0 Free Tier
  • MongoDB Server Version: 8.0.27 (Atlas)
  • Mongosh Version: 2.9.2
  • Connection Type: MongoDB Atlas (SRV)
  • Error:
    Unable to connect: querySrv ECONNREFUSED _mongodb._tcp.cluster0.lwaglnx.mongodb.net
    

Additional Information

The issue appears to be isolated to the MongoDB for VS Code extension. The same Atlas connection string works correctly in mongosh, indicating that the Atlas cluster, credentials, DNS resolution, and network configuration are all functioning correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions