DEV Community

Discussion on: Django + PostgreSQL Deployment on Railway App

Collapse
 
olaneat profile image
OlaNeat Ayoola

halo, i followed this and i'm getting this error when i apply migration
Image description

Collapse
 
mr_destructive profile image
Meet Rajesh Gor

Thank you for reading and giving feedback,

Make sure you have created the PostgreSQL database service on Railway, specified the DATABASE_URL properly in the .env file, and setup dj-database-url for smooth working of the database operations.

Also you could try an alternative way instead of installing and setting up the dj-database-url:

Let's say my database url is given by railway as:

postgres://sjxgipufegmgsw:78cbb568e@ec2-52-4-104-184.compute-1.amazonaws.com:5432/dbmuget
Enter fullscreen mode Exit fullscreen mode

This is of the format,

postgresql://user:password@hostname:port/db_name
Enter fullscreen mode Exit fullscreen mode

So, we can convert this URL into a object like representation of the remote database in django settings.

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "dbmuget",
        "USER": "sjxgipufegmgsw",
        "PASSWORD": "78cbb568e",
        "HOST": "ec2-52-4-104-184.compute-1.amazonaws.com",
        "PORT": 5432,
    }
}

Enter fullscreen mode Exit fullscreen mode

Try these few things out and let me if it still doesn't works.

Collapse
 
olaneat profile image
OlaNeat Ayoola

tnks this worked but now i'm getting a different err

Image description

Image description

Thread Thread
 
mr_destructive profile image
Meet Rajesh Gor

The address of the hostname must be taken from the URL and don't use Localhost.