首页 > 解决方案 > SQLSTATE[08006] 超时过期

问题描述

我正在尝试使用带有宅基地和 VirtualBox 的 Vagrand 将 laravel 项目连接到 postgresql 数据库,但是在迁移时我总是在下面收到此错误,我尝试更改主机和端口,但仍然相同。有人可以给我一个线索来解决这个问题吗?我查看了很多具有相同错误的问题,但没有一个有帮助,对不起,如果是简单的或者已经有一个应该解决的问题!

非常感谢!

Illuminate\Database\QueryException  : SQLSTATE[08006] [7] timeout expired (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)

 at /home/arthur/ERPet/erpet/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|

Exception trace:

1   PDOException::("SQLSTATE[08006] [7] timeout expired")
  /home/arthur/ERPet/erpet/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2   PDO::__construct("pgsql:host=192.168.10.10;dbname=erpet;port=5432;sslmode=prefer", "homestead", "secret", [])
  /home/arthur/ERPet/erpet/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

Please use the argument -v to see more details.

标签: laravelvagrantvirtualboxhomestead

解决方案


问题是,它没有连接到您的数据库。

我通过将端口从 50861 更改为 5432 解决了这个问题,这是我提供给 PostgreSQL 的默认端口。


推荐阅读