Cannot connect to MongoDB with public URL
fedealconada
PROOP

a year ago

I have an app with a mongo service. 2 environements (staging and production). I've been using staging fine but, somehow, on the production environment, I can't connect to the database. Production is basically a clone of staging.

On Railway's UI, if I go to the "data" tab, I can see this:

  • Deployment Online

    This service has an active deployment

  • Required Variables

    This service has all the necessary variables that this UI uses to connect to the database.

  • Database Connection

On the last bullet, there's constantly a spinner.

If I try connecting through CLI using mongosh:
```
mongosh PUBLIC_URL

Connecting to: mongodb://<credentials>@HOST:PORT/?directConnection=true&appName=mongosh+2.3.2

MongoServerSelectionError: read ECONNRESET
```

Solved

5 Replies

brody
EMPLOYEE

a year ago

Hello,

You have the TCP Proxy port pointing to 5433, when Mongo listens on 27017.

Attachments


Status changed to Awaiting User Response Railway about 1 year ago


fedealconada
PROOP

a year ago

On staging environment I have the same (port 5432) and it works fine... It's also the one that you can see by default on the UI when adding the TPC Proxy port...


Status changed to Awaiting Railway Response Railway about 1 year ago


brody
EMPLOYEE

a year ago

That is a placeholder -

https://www.w3schools.com/tags/att_input_placeholder.asp

Please use the correct port.


Status changed to Awaiting User Response Railway about 1 year ago


fedealconada
PROOP

a year ago

Yes, I know what a placeholder is, I'm just saying it because it is misleading... you could have a placeholder with the correct port. Still, you have not answered my question nor solved my issue. I mentioned that on the staging environment I'm using port 5432 without issues, so how come I can't use it on production?


Status changed to Awaiting Railway Response Railway about 1 year ago


brody
EMPLOYEE

a year ago

> you could have a placeholder with the correct port.

Since the TCP Proxy is a global primitive available for all services, the proxy doesn't know what is and isn't the correct port.

I do not know why it works, but I do know that it is not the port mongo listens on, please use the correct port for mongo and report back!


Status changed to Awaiting User Response Railway about 1 year ago


Railway
BOT

6 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 6 months ago


Loading...