首页 > 解决方案 > Symfony/Doctrine timeout expired sqlstate

问题描述

Hey guys so im trying to connect to my databse that's already created in postgresql (I'm using PGAdmin4 for the user interface of postgresql). I'm on Symfony CLI version v4.16.3 get three different Timeout.

In details i have a .env file that take the my database url :

DATABASE_URL=postgresql://root:password@127.0.0.1:35583/nd2d?serverVersion=12.3

My doctrice.yaml is set up like this :

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

I had issue but found a way to fix they were related to pdo drivers for postgresql. but after i launch the command bin/console make:migration i get those 3 errors:

In AbstractPostgreSQLDriver.php line 73:
                                                                        
  An exception occurred in driver: SQLSTATE[08006] [7] timeout expired



In PDOConnection.php line 31:
                                       
  SQLSTATE[08006] [7] timeout expired

In PDOConnection.php line 27:
                                       
  SQLSTATE[08006] [7] timeout expired

I avoided working on heavyn program with PHP or any framework related to it but this time i don't have a choice, soo much configuration i cant take it anymore, been on this for soo many hours now. What am i missing. Thank you :)

标签: phpormdoctrine-ormsymfony4

解决方案


Error came from listening on the wrong port, i was listening to the port 35583, which is the port that PgAdmin is showed on the web browse.

DATABASE_URL=postgresql://root:password@127.0.0.1:35583/nd2d?serverVersion=12.3

The port i should have been listening to is the default postgresql port of 5432


推荐阅读