Need help with Laravel MySQL

ejlocop
PRO

4 months ago

I kept getting an error: phpnetworkgetaddresses: getaddrinfo for mysql.railway.internal failed:

here's the part of the log.

3QoU3ltZm9ueVxcQ29tcG9uZW50XFxDb25zb2xlXFxPdXRwdXRcXENvbnNvbGVPdXRwdXQpKQojNDYgL2FwcC9hcnRpc2FuKDEzKTogSWxsdW1pbmF0ZVxcRm91bmRhdGlvblxcQXBwbGljYXRpb24tPmhhbmRsZUNvbW1hbmQoT2JqZWN0KFN5bWZvbnlcXENvbXBvbmVudFxcQ29uc29sZVxcSW5wdXRcXEFyZ3ZJbnB1dCkpCiM0NyB7bWFpbn0KIn0gCgo=","timestamp":"2025-04-15T16:02:48.408209781Z"}]}


   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql.railway.internal failed: Name or service not known (Connection: mysql, SQL: delete from `cache`)

{redacted}


  48  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))


✕ [11/12] RUN  chmod +x ./build-app.sh && sh ./build-app.sh 
process "/bin/bash -ol pipefail -c chmod +x ./build-app.sh && sh ./build-app.sh" did not complete successfully: exit code: 1


Dockerfile:25

-------------------

23 |     # build phase

24 |     COPY . /app/.

25 | >>> RUN  chmod +x ./build-app.sh && sh ./build-app.sh

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c chmod +x ./build-app.sh && sh ./build-app.sh" did not complete successfully: exit code: 1

Error: Docker build failed

build-app.sh contents:

#!/bin/bash
# Make sure this file has executable permissions, run `chmod +x build-app.sh`

# Exit the script if any command fails
set -e
php artisan optimize:clear
php artisan migrate --force
php artisan db:seed
php artisan config:cache
php artisan event:cache
php artisan route:cache
php artisan view:cache

and my laravel app's .env settings

DB_CONNECTION="mysql"
DB_HOST="localhost"
DB_PORT="3306"
DB_DATABASE={redacted}
DB_USERNAME="${{stMySQL.MYSQLUSER}}"
DB_PASSWORD="${{stMySQL.MYSQL_ROOT_PASSWORD}}"

anybody knows what went wrong? I appreciate any help. thank you

0 Replies

ejlocop
PRO

4 months ago

24503e6c-7e49-4436-b89c-707b567ef10e


ejlocop
PRO

4 months ago

I already searched the related errors here and still hasn't found a good solution.


ejlocop
PRO

4 months ago

Project ID: 24503e6c-7e49-4436-b89c-707b567ef10e


ejlocop
PRO

4 months ago

now I got the error when the script is runing php artisan migrate --force

staging.ERROR: SQLSTATE[HY000] [2002] phpnetworkgetaddresses: getaddrinfo for mysql.railway.internal failed: Name or service not known (Connection: mysql, SQL: select exists (select 1 from informationschema.tables where tableschema = 'railway' and tablename = 'migrations' and tabletype in ('BASE TABLE', 'SYSTEM VERSIONED')) as exists) {"exception":"[object] (Illuminate\Database\QueryException(code: 2002): SQLSTATE[HY000] [2002] phpnetworkgetaddresses: getaddrinfo for mysql.railway.internal failed: Name


ejlocop
PRO

4 months ago

NVM. I fixed it


ejlocop
PRO

4 months ago

!s