Railway CLI Laravel DB Seed command could not translate host name error

eraykuyumcu
PRO

2 months ago

I have a problem with my laravel application and Railway CLI.

When I enter:

railway run --service <servicename> php artisan db:seed

I got the an error which is = could not translate host name "postgres.railway.internal" to address:

What I try to do=
I try to php artisan tinker to enter tinker then
config('database.connections.pgsql.host') to see what is the db host name which is true = postgres.railway.internal

I try to run railway run DB_HOST="<publicDBAdress> then same run command

the error I got No such file or directory (os error 2)

Please help me to fix the problem.

Solved$10 Bounty

6 Replies

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody about 2 months ago


2 months ago

Hello,

Is your app able to connect over IPv6 ? (since Railway private domains only resolves to IPv6s)


eraykuyumcu
PRO

2 months ago

Our Laravel app should support IPv6 in theory, but since we're running seeding commands from a local development environment via railway run, it's likely that our local system or PHP environment maybe doesn't fully support IPv6 or resolve .internal domains properly. Is this the case maybe?


eraykuyumcu
PRO

2 months ago

I also try using railway shell -> then php artisan <command> which also gave the same could not translate host name error.


eraykuyumcu

I also try using railway shell -> then php artisan <command> which also gave the same could not translate host name error.

sim
FREE

2 months ago

A pre-deploy command might help here. According to their docs, it can handle tasks like running migrations or seeding data: https://docs.railway.com/guides/pre-deploy-command


sim

A pre-deploy command might help here. According to their docs, it can handle tasks like running migrations or seeding data: https://docs.railway.com/guides/pre-deploy-command

eraykuyumcu
PRO

2 months ago

it doesn't work too because I am using production server and the pre-deployment gives an error feed db is not allowed.


idiegea21
HOBBY

2 months ago

Guys,

the issue isn’t with Laravel or artisan itself, but with using postgres.railway.internal from your local machine via railway run, which can’t resolve that internal hostname. To fix it, just run your artisan command inside the Railway environment using:
railway ssh --service <your-laravel-service> https://station.railway.com/questions/laravel-artisan-command-via-cli-3fd464d8#259k


Status changed to Solved brody about 2 months ago