How could I connect to a mongodb database from railway?

loyahdev
PRO

a year ago

im searched online but its been a bit confusing based on what info railway gives me

0 Replies

loyahdev
PRO

a year ago

4c05d88f-1ba0-4c53-b525-f736d53d0a33


a year ago

may i ask whats confusing?

deploy mongo into your project, then setup reference variables on your desired service -

MONGO_URL=${{MongoDB.MONGO_URL}}

and then use the MONGO_URL environment variable in your code with whatever mongo client you like


loyahdev
PRO

a year ago

im trying to connect through mongodb vs code but its just saying:
Unable to load connection: MongoServerSelectionError: connection to 35.212.138.205:43765 closed


a year ago

you are trying to connect to mongodb on railway locally?


loyahdev
PRO

a year ago

yes


loyahdev
PRO

a year ago

im trying to connect to the railway mongodb server locally through vs code


a year ago

what does vscode have to do with this?


loyahdev
PRO

a year ago

im not specifically saying vs code it does the same error through terminal


loyahdev
PRO

a year ago

im jut trying to remove some entries in the database but i need to connect to it


a year ago

what database client are you trying to use


loyahdev
PRO

a year ago

im not using any


loyahdev
PRO

a year ago

im jusgt using vscode extensions


loyahdev
PRO

a year ago

that allow for database stuff


a year ago

try with dbgate


loyahdev
PRO

a year ago

on it


loyahdev
PRO

a year ago

this didnt seem to work

1240069143668199400


a year ago

i dont see an error?


loyahdev
PRO

a year ago

im trying to get one here


a year ago

click test


loyahdev
PRO

a year ago

same error that we got before

1240069355530621000


a year ago

what is the deployment status of the mongodb


loyahdev
PRO

a year ago

its active

1240069510208290800


a year ago

can you give me the host and port for the database?


loyahdev
PRO

a year ago


loyahdev
PRO

a year ago

43765


a year ago


a year ago

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
PRO

a year ago

nope im at home and arent using a firewall


loyahdev
PRO

a year ago

is there a way i could test jsut connecting to the port regularly?


a year ago

what os are you using?


loyahdev
PRO

a year ago

macos


loyahdev
PRO

a year ago

14.5


a year ago

does that come with the nc command?


loyahdev
PRO

a year ago

yup


a year ago

nc -zv [roundhouse.proxy.rlwy.net](roundhouse.proxy.rlwy.net) 43765


loyahdev
PRO

a year ago

jaxonhensch@MacBook-Pro-9 ~ % nc -zv roundhouse.proxy.rlwy.net 43765
Connection to roundhouse.proxy.rlwy.net port 43765 [tcp/*] succeeded!

loyahdev
PRO

a year ago

it works


a year ago

interesting


a year ago

try redeploying the database


loyahdev
PRO

a year ago

got it


loyahdev
PRO

a year ago

i get the same connection error


a year ago

can you connect to this with dbgate? - mongodb://mongo:mCLJxOdpiWxZHTXLNdateBAWzlDcLzWk@monorail.proxy.rlwy.net:50629


loyahdev
PRO

a year ago

yup i can


loyahdev
PRO

a year ago

it works


a year ago

screenshot of the tcp proxy for mongo please


loyahdev
PRO

a year ago

this?

1240072586130493700


a year 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
PRO

a year ago

do i have to redeploy?


loyahdev
PRO

a year ago

because i fixed it

1240073549830688800


a year ago

dont think so


a year ago

copy your new url and try with dbgate


loyahdev
PRO

a year ago

same error


loyahdev
PRO

a year ago

mongodb://mongo:(pass)@roundhouse.proxy.rlwy.net:37449

loyahdev
PRO

a year ago

Connect failed:  connection  to 35.212.138.205:37449 closed

a year ago

send me your mongo deloy logs please


loyahdev
PRO

a year ago


a year ago

have you tried to redeploy?


loyahdev
PRO

a year ago

not yet i will now


loyahdev
PRO

a year ago

it worked!


loyahdev
PRO

a year ago

connecting is perfect


a year ago

odd, but good!


loyahdev
PRO

a year ago

well thank you so much


a year ago

no problem!


a year ago

next time you open a help thread for an error, please include that error in the post