R
Railway9mo ago
Benzel

Project deployment spontaneously began crashing - Mongo Connection Error

Hello, I've had a project deployed through Railway for nearly a year now, but last week my deployment began crashing out of nowhere. I haven't made any adjustments to the code or modified any of the settings. The deployment logs show the error beginning with the following message: mongo connection error MongoServerSelectionError: Server selection timed out after 30000 ms It then traces the path where the error occurred and gives the following additional information (I've truncated the error due to length limits on posts in here, but can provide further info if needed):
reason: TopologyDescription {

type: 'Unknown',

servers: Map(1) {

'containers-us-west-28.railway.app:7635' => [ServerDescription]

},

stale: false,

compatible: true,

...
reason: TopologyDescription {

type: 'Unknown',

servers: Map(1) {

'containers-us-west-28.railway.app:7635' => [ServerDescription]

},

stale: false,

compatible: true,

...
Despite the error being listed as a Mongo connection error, there's no signs of issues in the deployment for the MongoDB instance that I have spun up for this project. Any ideas on what's causing this and how to fix it? I'm rather confused, given the above-mentioned lack of changes to source code or deployment settings. Hoping to get this figured out fairly soon, given that this is a project that I keep on my portfolio and I've recently begun testing the waters of the job market again. Thanks in advance!
Solution:
@Brody thanks for the help, I was able to fix it! I'll update this post with the appropriate tag. Back when I migrated my db, I added the new URI connection environment variable to my project but its default name wasn't what I had in my code so it kept using the old one (which I also forgot to delete lol)....
Jump to solution
8 Replies
Percy
Percy9mo ago
Project ID: 1d04f6ff-b2d5-47ba-bd7a-15255a675694
Benzel
BenzelOP9mo ago
1d04f6ff-b2d5-47ba-bd7a-15255a675694
Brody
Brody9mo ago
your app is still connecting to the deleted mongo database, please update your connection details https://docs.railway.app/guides/database-migration-guide#switching-over-connections
Benzel
BenzelOP9mo ago
I'll give that a shot, thanks for the feedback. I swear I already did it, but I must've misnamed the new variable or something. The issue doesn't seem to be happening on my other project that I have deployed through Railway.
Brody
Brody9mo ago
maybe it never used a legacy database
Benzel
BenzelOP9mo ago
It did, I had to go through this same process with it. Hopefully I just made a typo like I think I did and this is an easy fix
Solution
Benzel
Benzel9mo ago
@Brody thanks for the help, I was able to fix it! I'll update this post with the appropriate tag. Back when I migrated my db, I added the new URI connection environment variable to my project but its default name wasn't what I had in my code so it kept using the old one (which I also forgot to delete lol).
Brody
Brody9mo ago
yep that's been super common
Want results from more Discord servers?
Add your server