Connection refused. Is the server running on that host and accepting TCP/IP connections?

nalbright36PRO

a year ago

When trying to access the database in production, this is the error I receive. When I run the project locally, the issue does not occur.

For reference, this is a Django project. Any idea as to why I may be running into this issue?

Solved

11 Replies

a year ago

Are you using the private network to connect to the database? if not, please do.


nalbright36PRO

a year ago

I was not. Now, when I do try to change my 'HOST' to 'postgres.railway.internal' as the settings specify, I am now getting a host error. My settings are set up as follows:

'ENGINE': 'django.db.backends.postgresql',
'NAME': 'railway',
'USER': 'postgres',
'PASSWORD': '***********************',
'HOST': 'postgres.railway.internal',
'PORT': '25924',

Status changed to Awaiting Railway Response railway[bot] 11 months ago


a year ago

Please provide the error.

Are you on the V2 runtime? if not, try switching to it.


nalbright36PRO

a year ago

This is the local error when I try changing my HOST settings to 'postgres.railway.internal' :

django.db.utils.OperationalError: could not translate host name "postgres.railway.internal" to address: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.


nalbright36PRO

a year ago

I am on V2 runtime as well.


a year ago

You can not connect to the private domain locally, please push the changes and see if your app once running on Railway can connect to the database now.


nalbright36PRO

a year ago

I just pushed it and got a different error in production:

could not translate host name "postgres.railway.internal" to address: Name or service not known

a year ago

Is your database in the same project as your django service?


nalbright36PRO

a year ago

No. The Django project is hosted on pythonanywhere. The postgres database is all that is in Railway.


a year ago

Your django app and database would need to be in the same project in order to access the database over the private network, as it is now you are subjecting yourself to egress fees and increased latency.


nalbright36PRO

a year ago

Okay, thanks.


Status changed to Solved christian 11 months ago


Connection refused. Is the server running on that host and accepting TCP/IP connections? - Railway Help Station