Symfony SQLSTATE [HY000] [2002] Connection refused to server 1and1

I am trying to deploy my symfony api on server 1and1. But I can not get through this error:

request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused" ...

My symfony parameters.yml:

parameters:
    database_host: 127.0.0.1
    database_port: 3316
    database_name: myDbName
    database_user: MyUserName
    database_password: MyPassword
    database_unix_socket: /tmp/mysql5.sock

In config.ymlI add unix_socket:

doctrine:
    dbal:
    driver:   pdo_mysql
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    unix_socket: "%database_unix_socket%"
    charset:  UTF8

Has anyone commented on this mistake before?

+4
source share
2 answers

I changed 127.0.0.1 to localhost and now it works

+3
source

Have you checked your database settings?
Try using the default MySQL port, which is 3306

parameters.yml

    database_port: 3306

OR

Try using "/tmp/mysql5.sock" instead of "% database_unix_socket%" on your config.yml

config.yml

    unix_socket: /tmp/mysql5.sock
+1

All Articles