a month ago
Hi! Super new to the service here, trying to successfully deploy a Laravel backend
I've troubleshooted a bunch and it seems I'm on a good spot as of now, I have my app service connected to the github repo, and a postgres service. The connection to the database seems to be working, after configuring and deploying, I see all the tables in the postgres service 'data' tab.
The next step I'm trying is running an artisan command I created to be able to add a new admin user, because i removed the /register route/form from being accessed. So I went with the railway cli approach and I'm getting this error:
railway run php artisan admin:create-user
Enter the admin name:
> Diego ...
Enter the admin email:
Enter the admin password:
>
Illuminate\Database\QueryException
SQLSTATE[08006] [7] could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known (Connection: pgsql, SQL: select exists(select * from "users" where "email" = ...(redacted)@gmail.com) as "exists")
So I am finally asking for help around here, not sure what to do in this case
Thanks!
4 Replies
a month ago
Dear diegomrv I have the same problem with my laravel application and Railway CLI. When I enter railway run --service <servicename> php artisan db:seed I got the same name error which is = could not translate host name "postgres.railway.internal" to address:
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
there is a problem with railway and php artisan problem some how.
a month 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>
Then run your command like php artisan admin:create-user
. it’ll work perfectly there since the internal DB host is accessible from inside the container.
idiegea21
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>Then run your command like php artisan admin:create-user. it’ll work perfectly there since the internal DB host is accessible from inside the container.
a month ago
Kudos it help to solve the problem. I have also same problem in discussions with a bounty on it. wrote there so I accept as solution. thanks.
a month ago
Heyy @eraykuyumeu, I am happy it works now
it would help if you share the link to it.
Status changed to Solved chandrika • 27 days ago