I’m using Ubuntu in WSL2 in Windows 11.
Node v18.18.2 with Mongoose
I am in China and use Astrill VPN.
My connection string is:
DATABASE_URI=mongodb+srv://<my user name>:<my password>@my DB name>.mgxnkhk.mongodb.net/swic?retryWrites=true&w=majority
Config file:
try {
const conn = await mongoose.connect(process.env.DATABASE_URI, {
useUnifiedTopology: true,
useNewUrlParser: true,
});
console.log(`Database connected: ${conn.connection.host}`);
} catch (error) {
console.log(`Error: ${error.message}`);
process.exit(1);
}
};
When I do ‘npm run server’, I see this:
[nodemon] starting `node app.js`
App running on port 5000
Error: querySrv ECONNREFUSED _mongodb._tcp.swic.mgxnkhk.mongodb.net
[nodemon] app crashed - waiting for file changes before starting...
I’ve tried turning VPN on and off, switching VPN routes, all Windows firewalls are turned off, I am using the nearest cluster (Hong Kong), my DNS servers are set to Google.
I am able to connect when setting Astrill to stealth mode - otherwise, I keep getting this error.
While stealth mode is functional, I’d like to know if there is a better solution to this issue.
Thanks for any pointers.