Bronsii
Bronsii

Reputation: 1033

php_network_getaddresses: getaddrinfo failed: Hte inconnu

Hey guys I really hope to find a solution for my problem. so I can't find a solution for this problem and it keeps on appearing I'm using docker for my laravel+vue.js project and I've tried to run

docker-compose up -d

And everything seemed to be right but when I try to migrate my database :

php artisan migrate 

This error appears :

 Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Hte inconnu.  (SQL: select * from information_schema.tables where table_schema = pfe and table_name = migrations)

  at C:\xampp\htdocs\Laravel\Licence\vendor\laravel\framework\src\Illuminate\Database\Connection.php: 664
  660:         // If an exception occurs when attempting to run a query, we'll format the error
  661:         // message to include the bindings with SQL, which will make this exception a
  662:         // lot more helpful to the developer instead of just the database's errors.
  663:         catch (Exception $e) {
  664:             throw new QueryException(
  665:                 $query, $this->prepareBindings($bindings), $e
  666:             );
  667:         }
  668:
  669:         return $result;

  Exception trace:

  1   PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Hte inconnu. ")
      C:\xampp\htdocs\Laravel\Licence\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php : 70

  2   PDO::__construct("mysql:host=app_db;port=3306;dbname=pfe", "root", "", [])
      C:\xampp\htdocs\Laravel\Licence\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php : 70

  Please use the argument -v to see more details.

and this my .env file

NGINGX_ROOT=/usr/share/nginx/teamworking

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:EcJdGpFhoJWDLnbubsfwMBY1NGzSRXSS83bhTqmOhDc=
APP_DEBUG=true
APP_URL=127.0.0.1

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=app_db
DB_PORT=3306
DB_DATABASE=pfe
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=app_redis
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

JWT_SECRET=vpOw276VnRBlVENmQhnT7FtORham0JwJjVIX2iEKhlrlNgtFt4U1YtD9Xhg3yT5R

Upvotes: 0

Views: 6644

Answers (2)

TchD7
TchD7

Reputation: 1

Change DB_HOST=app_db to DB_HOST=localhost and migrate again.

Upvotes: 0

Smolindamix
Smolindamix

Reputation: 11

I had the same problem. The DB_HOST must be something like localhost or 127.0.0.1.

So in your case remplace DB_HOST=app_db by DB_HOST=localhost, and try again php artisan migrate.

You can put app_db after migration done.

I hope this help

Upvotes: 1

Related Questions