25 days ago
I try to connect to database, but it failed. i been digging but no luck.
Connection to MongoDB failed! MongoServerSelectionError: getaddrinfo ENOTFOUND mongodb.railway.internal
```log
Connection to MongoDB failed! MongoServerSelectionError: getaddrinfo ENOTFOUND mongodb.railway.internal
at Topology.selectServer (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/sdam/topology.ts:630:30)
at async Topology._connect (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/sdam/topology.ts:462:22)
at async Topology.connect (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/sdam/topology.ts:399:7)
at async topologyConnect (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/mongo_client.ts:662:9)
at async MongoClient._connect (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/mongo_client.ts:674:7)
at async MongoClient.connect (/app/node_modules/.pnpm/mongodb@7.0.0/node_modules/mongodb/src/mongo_client.ts:586:7)
```
import mongoose from 'mongoose';
import { config } from './config';
export const connectDatabase = async () => {
mongoose.set('strictQuery', false);
mongoose.connection.on('connected', () => {
// eslint-disable-next-line no-console
console.log('Connected to MongoDB!');
});
mongoose.connection.on('error', (err) => {
// eslint-disable-next-line no-console
console.error('Connection to MongoDB failed!', err);
});
await mongoose.connect(config.mongo_url, { family: 6 });
};
import dns from 'node:dns';
dns.setDefaultResultOrder('ipv6first');1 Replies
25 days ago
Fixed that for you. You had deployed Mongo right before we pushed out a fix.
Please swap the connection use back to the private address.
Status changed to Awaiting User Response brody • 25 days ago
18 days ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 18 days ago
