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

eraykuyumcu
PRO

6 days 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.

$10 Bounty

5 Replies

6 days 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 6 days ago


mateodemuynck
PRO

6 days ago

Hello,

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


eraykuyumcu
PRO

6 days 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

5 days 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
FREETop 1% Contributor

3 days 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

16 hours ago

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