3 months ago
Hello, I created a PostgreSQL service to connect my flask backend to it, but first I want to migrate the database from my local machine running "flask db migrate" and "flask db upgrade" to add the empty tables. My flask app takes the database URL from a .env, and I put the public URL there and run the commands, but it doesn't work, because it says:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "postgres.railway.internal" to address: Name or service not known
It's like I'm trying to use the private one, but I'm using the DATABASE_PUBLIC_URL and not the DATABASE_URL. I have read some threads about this issue and none of them helped me. If I run the psql locally using the DATABASE_PUBLIC_URL I can connect, but putting the URL in my .env doesn't work.
3 Replies
3 months ago
Hello,
You need to make sure you are using the database public host and port when running migrations locally.
Best,
Brody
Status changed to Awaiting User Response railway[bot] • 3 months ago
brody
Hello,You need to make sure you are using the database public host and port when running migrations locally.Best,Brody
3 months ago
Hi, yeah, I'm using the public one that is created by Railway (DATABASE_PUBLIC_URL), but I tried something else, and that was restarting the VS Code where I was trying to run the commands and now it worked, and I don't know why that worked, but it worked, haha. So, now I could add the migrations. Thanks for the quick response.
Status changed to Awaiting Railway Response railway[bot] • 3 months ago
Status changed to Awaiting User Response railway[bot] • 3 months ago
Status changed to Solved brody • 3 months ago