Robinson
Robinson

Reputation: 85

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

I am trying to deploy my symfony api on a 1and1 server. But I can't get pass 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 the config.yml I add the 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

Is someone pass thought this error before?

Upvotes: 4

Views: 9330

Answers (2)

Robinson
Robinson

Reputation: 85

I changed 127.0.0.1 by localhost and now it's working

Upvotes: 3

warDevyll
warDevyll

Reputation: 47

Have you verified your database parameters?
Try using the default MySQL Port which is 3306

parameters.yml

    database_port: 3306

OR

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

config.yml

    unix_socket: /tmp/mysql5.sock

Upvotes: 1

Related Questions