0

I'm using mamp the latest php7.4.12 and Apache, i don't understand what is it, i search for this error : "An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?"

In my .env

DATABASE_URL="mysql://root:@db_docker_symfony:3306/test_docker?serverVersion=5.7"

and doctrine.yaml

dbal:
        url: '%env(resolve:DATABASE_URL)%'

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        #server_version: '13'
    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
devFanch
  • 3
  • 4
  • Does this answer your question? ["psql: could not connect to server: Connection refused" Error when connecting to remote database](https://stackoverflow.com/questions/32439167/psql-could-not-connect-to-server-connection-refused-error-when-connecting-to) – Anish Chikodi Jan 23 '21 at 02:42
  • No, because i'would like to connect my app with mysql, but i don't know why symfony try to connect with pgsql instead of mysql cf .env file – devFanch Jan 23 '21 at 12:32

1 Answers1

0

I had the same problem and basically you might have the postgresql uncommented... this port 5432 is related to the postgresql connection, so you just need to comment this line out using "#" ... as you can see below,

#DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"

leave only you mysql connection uncommented and boom! Happy days hey \o/...

I reackon .env comes with postgresql as a default connection.

Hopefully works for you as well.