2

I use Symfony 3.1.5 and I am trying to run a simple

php bin/console doctrine:database:create

as it is described in the documentation.

My parameters.yml

parameters:
    database_host: hhvm_db_1
    database_port: 5432
    database_name: dbname
    database_user: dbuser
    database_password: mypassword

My config.yml

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

I get the following error messages:

  [Doctrine\DBAL\Exception\DriverException]
  An exception occured in driver: [32681]: could not translate host name "hhvm_db_1
  port=5432 dbname=postgres " to address: Name or service not known



  [Doctrine\DBAL\Driver\PDOException]
  [32681]: could not translate host name "hhvm_db_1 port=5432 dbname=postgres " to a
  ddress: Name or service not known



  [PDOException]
  [32681]: could not translate host name "hhvm_db_1 port=5432 dbname=postgres " to a
  ddress: Name or service not known

The error message looks odd to me, because it states dbname=postgres while I have a different database specified in my parameters.yml. I tried to change it directly in the config.yml, but that does not change a thing. Database host and port are taken from my parameters.yml though.

I suppose doctrine is just using default parameters for dbname, as it cannot parse my parameters for some reason. What could be the problem here?

I don't think this is really the issue, but I am running symfony in a docker container with hhvm. hhvm_db_1 in the above error message is the second container running Postgres. When I check the connection with vanilla PHP it works and I can connect to the database. Thus, the host is accessible from my web container.

4
  • Is it possible you're including another config file that might be overriding the dbname? Commented Nov 2, 2016 at 18:43
  • This is quite a fresh installation of symfony. There is only one parameters.yml and the config files for the different environments (test, dev, prod). None of them holds an additional database configuration. But that was why I asked for a way to debug the console script. Commented Nov 2, 2016 at 19:48
  • IIRC, including the command flag -vvv will increase the logging to the maximum level, which could help with debugging. Commented Nov 2, 2016 at 19:49
  • Thanks for your help. This outputs the stack trace alongside, but it does not really produce something insightful. Commented Nov 2, 2016 at 19:54

1 Answer 1

1

I found that my system is having problems with the dsn string containing spaces instead of semicolons.

Does not work:

pgsql:host=hhvm_db_1 port=5432 dbname=postgres

Works fine:

pgsql:host=hhvm_db_1;port=5432;dbname=postgres

My initial problem was also solved by that. The DBAL driver for PDOPgSQL is using postgres as the default database to check the connection.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.