Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (Laravel 8 migration error) [closed]

After new laravel8 jetstream with livewire fresh installed when I run the command php artisan migrate then it gives the error on my terminal

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.  (SQL: select * from information_schema.tables where table_schema = lweb and table_name = migrations and table_type = 'BASE TABLE')

  at C:\xampp\htdocs\liveweb\vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕

  1   C:\xampp\htdocs\liveweb\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. ")

  2   C:\xampp\htdocs\liveweb\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=mysql;port=3306;dbname=lweb", "root", "", [])
PS C:\xampp\htdocs\liveweb> 
like image 427
mdmunirujjaman27 Avatar asked Oct 23 '25 11:10

mdmunirujjaman27


1 Answers

Problem solve just remove DB_HOST=mysql

DB_CONNECTION=mysql
DB_HOST=localhost
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=lweb
DB_USERNAME=root
DB_PASSWORD=
  

To

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lweb
DB_USERNAME=root
DB_PASSWORD=
like image 157
mdmunirujjaman27 Avatar answered Oct 26 '25 00:10

mdmunirujjaman27



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!