SQLSTATE [08006]超时已过期

时间:2019-03-10 16:44:26

标签: laravel vagrant virtualbox homestead

我正在尝试使用带有Homestead和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.

1 个答案:

答案 0 :(得分:0)

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

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