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):
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:Jump to 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)....
8 Replies
Project ID:
1d04f6ff-b2d5-47ba-bd7a-15255a675694
1d04f6ff-b2d5-47ba-bd7a-15255a675694
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
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.
maybe it never used a legacy database
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
@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).
yep that's been super common