We have a working app that successfully returns a token from /auth/user-token using Symfony 4 and Lexik JWT Authentication Bundle. After I install JWTRefreshTokenBundle, (completing the installation up through step 3), however, I get this error when visiting that existing endpoint:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Reverting my files to a pre-installation state allows the app to work again.
Does anyone have any ideas about what might be going on here?
===
Update: Attempting to run the installation through step 5 (schema update) results in this error:
In AbstractMySQLDriver.php line 113:
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 50:
SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 46:
SQLSTATE[HY000] [2002] Connection refused
You have to install mysql and then add the following line to your .env file at symfony root:
DATABASE_URL="mysql://db_user:db_password#127.0.0.1:3306/db_name"
Then replace the following values with desired values:
db_user your database user
db_password your database password
db_name your database name
Then do the following changes in config/packages/doctrine.yaml:
doctrine:
dbal:
url: '%env(DATABASE_URL)%'
Related
when i run any php artisan commands make,key its throwing an error saying
In Connection.php line 664:
SQLSTATE[HY000] [2002] No connection could be made because the
target machine actively refused it. (SQL: select * from system
where key = woocommerce_version limit 1)
In Connector.php line 70:
SQLSTATE[HY000] [2002] No connection could be made because the
target machine actively refused it.
why it tries to connect to mysql database it has nothing to do with it
my server is iis i don't know if its mis-configured, but the same laravel application in localhost shows no error
I have been working on an existing laravel API project where they always have a sudden error of
local.ERROR: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution at /var/www/html/web/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31)
[stacktrace]
sometimes it goes away by restarting the AWS instance or other times it remains there. however, the problem is that it is a running website why this problem is occurring and resolves itself and the website has been down for many hours because of this error and this time restarting the AWS instance doesn't even help.
I can access the database via workbench but can't access it from there website.
what is going on?
I am trying to run
php bin/console make:migration
I received these errors
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
In PDOConnection.php line 27:
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
I have checked all of my .env files. I have configured the
DATABASE_URL=mysql://mylocalDb:#fL3#&_{Dx3N#127.0.0.1:3306/LocalDataBase
I have changed the doctrine config to use server_version: '5.7'. I don't know for sure if that correct. I just removed the # from in front of the line because of the note that said you must configure your server version. But not sure which server it is referring to.
So, my question is how do I test the database connection in Symfony. I have searched the documents and was unable to find a clear answer to this question. When I run
php bin/console doctrine:database:create
This produces an error
In CreateDatabaseDoctrineCommand.php line 82:
Connection does not contain a 'path' or 'dbname' parameter and cannot be created.
I have cleared my cache twice after making config changes and still receive the same error messages.
What other ways can I test the db connection.
https://symfony.com/doc/current/doctrine.html#configuring-the-database
Your DB password contains '#' which breaks Symfony's parser, changing the password to not have the symbol should resolve your issue.
Like ikyuchukov said, the "#" character breaks the parsing. But instead of changing your password, url-encoding this character will do a better job, in my opinion. You can replace it with it's url-encoded value "%40".
I'm a fresh junior php developer and I'm building my first Symfony project.
When I used the command : php bin/console doctrine:database:create
I get these errors :
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] No such file or directory*
I'm actually using MAMP with default config "db_user" and "db_password"
so I edited the .env file with this following code :
DATABASE_URL=mysql://root:root#localhost:8889/mydbname
I know there is something wrong with my host or port, I saw on other topics that some users using MAMP keep Symfony default values for host and port : DATABASE_URL=mysql://root:root#127.0.0.1:3306/mydbname
Thanks for reading me and trying to help me.
I did more searches and some people are saying that localhost syntax is depreciated and prefer using : 127.0.0.1 instead of localhost.
In my case I checked and used Mamp config 'Connect using an UNIX socket'
So it's now working with :
DATABASE_URL=mysql://root:root#127.0.0.1:8889/mydbname
I am trying to create a database in symfony 4 using php bin/console doctrine:database:create command in terminal, but I keep getting the same 3 errors:
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] Connection refused
There are a few similar problems which seem to be solved by changing 127.0.0.1 to localhost in the .env file DATABASE_URL line, but none of these solutions fix the problem. Changing to localhost for me gives the same error but 'no such file or directory' instead of 'connection refused'.