How could I connect to a mongodb database from railway?

im searched online but its been a bit confusing based on what info railway gives me
47 Replies
Percy
Percy7mo ago
Project ID: 4c05d88f-1ba0-4c53-b525-f736d53d0a33
loyahdev
loyahdevOP7mo ago
4c05d88f-1ba0-4c53-b525-f736d53d0a33
Brody
Brody7mo ago
may i ask whats confusing? deploy mongo into your project, then setup reference variables on your desired service -
MONGO_URL=${{MongoDB.MONGO_URL}}
MONGO_URL=${{MongoDB.MONGO_URL}}
and then use the MONGO_URL environment variable in your code with whatever mongo client you like
loyahdev
loyahdevOP7mo ago
im trying to connect through mongodb vs code but its just saying: Unable to load connection: MongoServerSelectionError: connection <monitor> to 35.212.138.205:43765 closed
Brody
Brody7mo ago
you are trying to connect to mongodb on railway locally?
loyahdev
loyahdevOP7mo ago
yes im trying to connect to the railway mongodb server locally through vs code
Brody
Brody7mo ago
what does vscode have to do with this?
loyahdev
loyahdevOP7mo ago
im not specifically saying vs code it does the same error through terminal im jut trying to remove some entries in the database but i need to connect to it
Brody
Brody7mo ago
what database client are you trying to use
loyahdev
loyahdevOP7mo ago
im not using any im jusgt using vscode extensions that allow for database stuff
Brody
Brody7mo ago
try with dbgate
loyahdev
loyahdevOP7mo ago
on it
loyahdev
loyahdevOP7mo ago
this didnt seem to work
No description
Brody
Brody7mo ago
i dont see an error?
loyahdev
loyahdevOP7mo ago
im trying to get one here
Brody
Brody7mo ago
click test
loyahdev
loyahdevOP7mo ago
same error that we got before
No description
Brody
Brody7mo ago
what is the deployment status of the mongodb
loyahdev
loyahdevOP7mo ago
its active
No description
Brody
Brody7mo ago
can you give me the host and port for the database?
loyahdev
loyahdevOP7mo ago
roundhouse.proxy.rlwy.net 43765
Brody
Brody7mo ago
https://utilities.up.railway.app/port-check?host=roundhouse.proxy.rlwy.net&port=43765 are you on school, work, public internet? you could be behind a firewall that blocks non common ports, 43765 is not a common port
loyahdev
loyahdevOP7mo ago
nope im at home and arent using a firewall is there a way i could test jsut connecting to the port regularly?
Brody
Brody7mo ago
what os are you using?
loyahdev
loyahdevOP7mo ago
macos 14.5
Brody
Brody7mo ago
does that come with the nc command?
loyahdev
loyahdevOP7mo ago
yup
Brody
Brody7mo ago
nc -zv roundhouse.proxy.rlwy.net 43765
loyahdev
loyahdevOP7mo ago
jaxonhensch@MacBook-Pro-9 ~ % nc -zv roundhouse.proxy.rlwy.net 43765
Connection to roundhouse.proxy.rlwy.net port 43765 [tcp/*] succeeded!
jaxonhensch@MacBook-Pro-9 ~ % nc -zv roundhouse.proxy.rlwy.net 43765
Connection to roundhouse.proxy.rlwy.net port 43765 [tcp/*] succeeded!
it works
Brody
Brody7mo ago
interesting try redeploying the database
loyahdev
loyahdevOP7mo ago
got it i get the same connection error
Brody
Brody7mo ago
can you connect to this with dbgate? - mongodb://mongo:[email protected]:50629
loyahdev
loyahdevOP7mo ago
yup i can it works
Brody
Brody7mo ago
screenshot of the tcp proxy for mongo please
loyahdev
loyahdevOP7mo ago
this?
No description
Brody
Brody7mo ago
yeah, 27021 is wrong, remove the proxy and add it back with 27017, this will then change the url service variable so be sure to copy it again and try with dbgate
loyahdev
loyahdevOP7mo ago
do i have to redeploy?
loyahdev
loyahdevOP7mo ago
because i fixed it
No description
Brody
Brody7mo ago
dont think so copy your new url and try with dbgate
loyahdev
loyahdevOP7mo ago
same error
mongodb://mongo:(pass)@roundhouse.proxy.rlwy.net:37449
mongodb://mongo:(pass)@roundhouse.proxy.rlwy.net:37449
Connect failed: connection <monitor> to 35.212.138.205:37449 closed
Connect failed: connection <monitor> to 35.212.138.205:37449 closed
Brody
Brody7mo ago
send me your mongo deloy logs please https://bookmarklets.up.railway.app/log-downloader/
Brody
Brody7mo ago
have you tried to redeploy?
loyahdev
loyahdevOP7mo ago
not yet i will now it worked! connecting is perfect
Brody
Brody7mo ago
odd, but good!
loyahdev
loyahdevOP7mo ago
well thank you so much
Brody
Brody7mo ago
no problem! next time you open a help thread for an error, please include that error in the post
Want results from more Discord servers?
Add your server