Skip to content

Node.js process cannot resolve the DNS SRV records #62703

@shivarm

Description

@shivarm

Version

v24.13.0

Platform

Windows 11

Subsystem

No response

What steps will reproduce the bug?

Node.js process cannot resolve the DNS SRV records used by the mongodb+srv:// connection string.

import express from "express";
import connectDB from "./db.js";
 
const app = express();

app.use(express.json());
 
// Start server with error handling
app.listen(PORT, (err) => {
  if (err) {
    console.error("Server startup error:", err.message);
    process.exit(1);
  }
  console.log(`Server is running on port ${PORT}`);
  connectDB();
});

npm run start

How often does it reproduce? Is there a required condition?

Just need a express app with mongoose lib to connect mongoDB connection string

What is the expected behavior? Why is that the expected behavior?

Server is running on port 5000
MongoDB connected

What do you see instead?

Server is running on port 5000
MongoDB connection error: querySrv ECONNREFUSED _mongodb._tcp.cryptomarketplace.uaakapd.mongodb.net
Failed running 'index.js'. Waiting for file changes before restarting...

Additional information

No response

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