a year ago
I published a Django project using SQLite. This was a bad idea, and I am now trying to migrate it to PostgreSQL after the fact. This is the configuration:
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('PGDATABASE'),
'USER': os.getenv('PGUSER'),
'PASSWORD': os.getenv('PGPASSWORD'),
'HOST': 'autorack.proxy.rlwy.net',
'PORT': os.getenv('PGPASSWORD'),
}
}All the environment variables have had references set up so they can be accessed. However, whenever I try to do railway run python manage.py migrate from with the Railway CLI, I get this error:
django.db.utils.OperationalError: connection to server at "autorack.proxy.rlwy.net (35.212.52.114), port 5432 failed: Connection timed out (0x0000274C/10060) Is the server running on that host and accepting TCP/IP connections?
I don't know what I am doing wrong here. I'm trying to connect to the PostgreSQL database I created from the CLI on my computer. I really do not know what else to do here.
9 Replies
a year ago
That is a typo, but it threw this exact same error when I just had 5432 typed in for the port.
a year ago
You have the host incorrect.
You are using the private port, thus you need to use the private hostname.
a year ago
I set the host to that because it said it couldn't identify the host when I used the private hostname.
a year ago
When I try the private host, it throws django.db.utils.OperationalError: could not translate host name "postgres.railway.internal" to address: No such host is known.
a year ago
On Railway your app should use the private host + port, locally you need to use the pubic host + port.
a year ago
So on the app use postgres.railway.internal and port 5432, and locally use autorack.proxy.rlwy.net and 33732?
Status changed to Solved brody • about 1 year ago
