How could I connect to a mongodb database from railway?
loyahdev
PROOP

2 years ago

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

0 Replies

loyahdev
PROOP

2 years ago

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


brody
EMPLOYEE

2 years 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
PROOP

2 years 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


brody
EMPLOYEE

2 years ago

you are trying to connect to mongodb on railway locally?


loyahdev
PROOP

2 years ago

yes


loyahdev
PROOP

2 years ago

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


brody
EMPLOYEE

2 years ago

what does vscode have to do with this?


loyahdev
PROOP

2 years ago

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


loyahdev
PROOP

2 years ago

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


brody
EMPLOYEE

2 years ago

what database client are you trying to use


loyahdev
PROOP

2 years ago

im not using any


loyahdev
PROOP

2 years ago

im jusgt using vscode extensions


loyahdev
PROOP

2 years ago

that allow for database stuff


brody
EMPLOYEE

2 years ago

try with dbgate


loyahdev
PROOP

2 years ago

on it


loyahdev
PROOP

2 years ago

this didnt seem to work

1240069143668199400


brody
EMPLOYEE

2 years ago

i dont see an error?


loyahdev
PROOP

2 years ago

im trying to get one here


brody
EMPLOYEE

2 years ago

click test


loyahdev
PROOP

2 years ago

same error that we got before

1240069355530621000


brody
EMPLOYEE

2 years ago

what is the deployment status of the mongodb


loyahdev
PROOP

2 years ago

its active

1240069510208290800


brody
EMPLOYEE

2 years ago

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


loyahdev
PROOP

2 years ago


loyahdev
PROOP

2 years ago

43765


brody
EMPLOYEE

2 years ago


brody
EMPLOYEE

2 years 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
PROOP

2 years ago

nope im at home and arent using a firewall


loyahdev
PROOP

2 years ago

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


brody
EMPLOYEE

2 years ago

what os are you using?


loyahdev
PROOP

2 years ago

macos


loyahdev
PROOP

2 years ago

14.5


brody
EMPLOYEE

2 years ago

does that come with the nc command?


loyahdev
PROOP

2 years ago

yup


brody
EMPLOYEE

2 years ago

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


loyahdev
PROOP

2 years ago

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

loyahdev
PROOP

2 years ago

it works


brody
EMPLOYEE

2 years ago

interesting


brody
EMPLOYEE

2 years ago

try redeploying the database


loyahdev
PROOP

2 years ago

got it


loyahdev
PROOP

2 years ago

i get the same connection error


brody
EMPLOYEE

2 years ago

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


loyahdev
PROOP

2 years ago

yup i can


loyahdev
PROOP

2 years ago

it works


brody
EMPLOYEE

2 years ago

screenshot of the tcp proxy for mongo please


loyahdev
PROOP

2 years ago

this?

1240072586130493700


brody
EMPLOYEE

2 years 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
PROOP

2 years ago

do i have to redeploy?


loyahdev
PROOP

2 years ago

because i fixed it

1240073549830688800


brody
EMPLOYEE

2 years ago

dont think so


brody
EMPLOYEE

2 years ago

copy your new url and try with dbgate


loyahdev
PROOP

2 years ago

same error


loyahdev
PROOP

2 years ago

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

loyahdev
PROOP

2 years ago

Connect failed:  connection  to 35.212.138.205:37449 closed

brody
EMPLOYEE

2 years ago

send me your mongo deloy logs please


loyahdev
PROOP

2 years ago


brody
EMPLOYEE

2 years ago

have you tried to redeploy?


loyahdev
PROOP

2 years ago

not yet i will now


loyahdev
PROOP

2 years ago

it worked!


loyahdev
PROOP

2 years ago

connecting is perfect


brody
EMPLOYEE

2 years ago

odd, but good!


loyahdev
PROOP

2 years ago

well thank you so much


brody
EMPLOYEE

2 years ago

no problem!


brody
EMPLOYEE

2 years ago

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


Loading...