Can't run railway run on Ubuntu
mfrancisca
HOBBYOP

2 months ago

Hello!

I've started my first railway project: a Django + Postgres website. I'm trying to run python manage.py createsupersuer through the railway cli to create my admin user but I'm getting this error:

django.db.utils.OperationalError: failed to resolve host 'postgres.railway.internal': [Errno -2] Name or service not known

The commands I've run are

railway login
railway link
railway service
railway run python manage.py createsuperuser

The database configuration in my django settings is done through dj_database_url

DATABASES = {
    'default': dj_database_url.config(conn_max_age=600, conn_health_checks=True)
}

Am I missing something? What am I doing wrong?

Solved$10 Bounty

Pinned Solution

There's a variable called DATABASE_PUBLIC_URL which you can use.

3 Replies

Status changed to Open Railway 2 months ago


you're using internal url which can only be used internally from one service to another, use the public url instead


Status changed to Solved Railway 2 months ago


mfrancisca
HOBBYOP

2 months ago

OK, so how do I set it to use the public database url? Do I need a special settings file for when I connect to the shell?


Status changed to Awaiting Railway Response Railway 2 months ago


mfrancisca

OK, so how do I set it to use the public database url? Do I need a special settings file for when I connect to the shell?

There's a variable called DATABASE_PUBLIC_URL which you can use.


Status changed to Solved 0x5b62656e5d 17 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...