Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known #1734

Closed
da4id opened this issue Sep 26, 2018 · 7 comments

Comments

@da4id
Copy link

da4id commented Sep 26, 2018

I am running Firefly III version x.x.x

Description
I got error SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
when i try to run it in Docker. I followed the step by step tutorial for docker installaiton. The error comes up after i run docker exec -it <container> php artisan migrate --seed

Extra info
Please add extra info here, such as OS, browser, and the output from the /debug-page of your Firefly III installation (click the version at the bottom).

[2018-09-26 20:03:00] local.ERROR: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known {"exception":"[object] (Doctrine\DBAL\Driver\PDOException(code: 2002): SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known at /var/www/firefly-iii/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50, PDOException(code: 2002): SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known at /var/www/firefly-iii/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46, PDOException(code: 0): PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known at /var/www/firefly-iii/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46)
[stacktrace]
#0 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(65): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=CHAN...', 'CHANGEME', 'CHANGEME', Array)
#1 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(98): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=CHAN...', 'CHANGEME', 'CHANGEME', Array)
#2 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(48): Illuminate\Database\Connectors\Connector->tryAgainIfCausedByLostConnection(Object(Doctrine\DBAL\Driver\PDOException), 'mysql:host=CHAN...', 'CHANGEME', 'CHANGEME', Array)
#3 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=CHAN...', Array, Array)
#4 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(182): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#5 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#6 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(915): call_user_func(Object(Closure))
#7 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(248): Illuminate\Database\Connection->getPdo()
#8 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(234): Illuminate\Database\DatabaseManager->refreshPdoConnections('mysql')
#9 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(168): Illuminate\Database\DatabaseManager->reconnect('mysql')
#10 [internal function]: Illuminate\Database\DatabaseManager->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection))
#11 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(753): call_user_func(Object(Closure), Object(Illuminate\Database\MySqlConnection))
#12 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(735): Illuminate\Database\Connection->reconnect()
#13 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(717): Illuminate\Database\Connection->tryAgainIfCausedByLostConnection(Object(Illuminate\Database\QueryException), 'select * from i...', Array, Object(Closure))
#14 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(627): Illuminate\Database\Connection->handleQueryException(Object(Illuminate\Database\QueryException), 'select * from i...', Array, Object(Closure))
#15 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\Database\Connection->run('select * from i...', Array, Object(Closure))
#16 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php(18): Illuminate\Database\Connection->select('select * from i...', Array)
#17 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(169): Illuminate\Database\Schema\MySqlBuilder->hasTable('migrations')
#18 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(555): Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
#19 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(97): Illuminate\Database\Migrations\Migrator->repositoryExists()
#20 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(63): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#21 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->handle()
#22 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#23 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#24 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#25 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#26 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\Container\Container->call(Array)
#27 /var/www/firefly-iii/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#28 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#29 /var/www/firefly-iii/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/firefly-iii/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/firefly-iii/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /var/www/firefly-iii/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 {main}
"}

In PDOConnection.php line 50:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

In PDOConnection.php line 46:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

In PDOConnection.php line 46:

PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

@hamuz
Copy link
Contributor

hamuz commented Sep 26, 2018

Looks like the database information provided is invalid. (wrong database host address)

@JC5
Copy link
Member

JC5 commented Sep 27, 2018

What's the entire command you use to run the Docker container? Are you sure you refer to a database that can be reached from within the container?

@JC5 JC5 added the question label Sep 27, 2018
@da4id
Copy link
Author

da4id commented Sep 27, 2018

docker run -d \
-v firefly_iii_export:/var/www/firefly-iii/storage/export \
-v firefly_iii_upload:/var/www/firefly-iii/storage/upload \
-p 80:80 \
-e FF_APP_ENV=local \
-e FF_APP_KEY=S0m3R@nd0mString0f32Ch@rsEx@ct1y \
-e FF_DB_HOST=CHANGEME \
-e FF_DB_NAME=CHANGEME \
-e FF_DB_USER=CHANGEME \
-e FF_DB_PASSWORD=CHANGEME \
jc5x/firefly-iii:latest

I found the problem I did not changed all CHANGEME Fields....

@da4id da4id closed this as completed Sep 27, 2018
@da4id da4id reopened this Sep 27, 2018
@da4id
Copy link
Author

da4id commented Sep 27, 2018

When i run the same command now, i get another error
`[2018-09-27 19:43:06] local.ERROR: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = ff and table_name = migrations) {"exception":"[object] (Illuminate\Database\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = ff and table_name = migrations) at /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /var/www/firefly-iii/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /var/www/firefly-iii/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46)
[stacktrace]
#0 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('select * from i...', Array, Object(Closure))
#1 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\Database\Connection->run('select * from i...', Array, Object(Closure))
#2 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php(18): Illuminate\Database\Connection->select('select * from i...', Array)
#3 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(169): Illuminate\Database\Schema\MySqlBuilder->hasTable('migrations')
#4 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(555): Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
#5 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(97): Illuminate\Database\Migrations\Migrator->repositoryExists()
#6 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(63): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#7 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->handle()
#8 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#9 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#10 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#11 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#12 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\Container\Container->call(Array)
#13 /var/www/firefly-iii/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#14 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#15 /var/www/firefly-iii/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/firefly-iii/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/firefly-iii/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/firefly-iii/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/firefly-iii/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 {main}
"}

In Connection.php line 664:

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = ff and table_name = migrations)

In PDOConnection.php line 50:

SQLSTATE[HY000] [2002] No such file or directory

In PDOConnection.php line 46:

SQLSTATE[HY000] [2002] No such file or directory

`

I checked Database access for the User. It works with the cresendials provided in docker run command

@da4id
Copy link
Author

da4id commented Sep 27, 2018

The sql statement from the errormessage does not work
select * from information_schema.tables where table_schema = ff and table_name = migrations
ff is my database name
When i change the statement to
select * from information_schema.tables where table_schema = 'ff' and table_name = 'migrations';
It works and returns empty set.

@da4id
Copy link
Author

da4id commented Sep 27, 2018

I got it
In my runconfig the mysql serverip was localhost. I tried also 127.0.0.1. But this should be the real server Ip. Then it works.
I Think this information and also that a mysql server is required should be described in the tutorial

@da4id da4id closed this as completed Sep 27, 2018
@b12f
Copy link

b12f commented Oct 10, 2018

@da4id if both the mysql and the firefly instance are running on the same server inside docker, just create a docker network with and connect both containers to it. Then FIREFLY_DB_HOST should be the name of the mysql container. It's better security-wise since the mysql instance isn't publicly available.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants