MySQL randomly says SQLSTATE[HY000] [2002] Connection Refused - php

Using PHP, Symfony Framework, MySQL.
Switched to new server.
System randomly triggers SQLSTATE[HY000] [2002] Connection refused. Does this related to server/database setting?
Database setting adjusted:
max_allowed_packet: 268435456

Related

SQLSTATE[HY000] [2002] (trying to connect via (null)) when connecting to digitalocean managed db

I am using digitalocean managed DB in my laravel app . Everything working fine in tinker mode but when using in app it throws
SQLSTATE[HY000] [2002] (trying to connect via (null))
error . even i can connect it from beekeeper studio.
here's my configuration.
DB_CONNECTION=mysql
DB_HOST=obilia-***.db.ondigitalocean.com
DB_PORT=25060
DB_DATABASE=defaultdb
DB_USERNAME=**********
DB_PASSWORD=**********
DB_SSLMODE=required
MYSQL_ATTR_SSL_CA=storage/cert/ca-certificate.crt

php artisan make controller command try connecting to mysql and throwing connection error

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

sudden error of QLSTATE[HY000] [2002] php_network_getaddresses

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?

Mysql Remote Connection Failed

Im trying with php to connect my remote server's mysql im getting this error:
"Database Connection Error: SQLSTATE[HY000] [2002] connection refused"
I made what said in that page : https://www.configserverfirewall.com/ubuntu-linux/enable-mysql-remote-access-ubuntu/
this is my setting now:
and ofcourse restarted mysql.
ANd its still saying same error "Database Connection Error: SQLSTATE[HY000] [2002] connection refused"
What can i do else?
this is my connection setting:
When i try port 3306 same error. What can cause that?
ps: also this is a remote connection from a hosting shared to my dedicated server
it was about cloudflare or other proxies. Fixed.

JWTRefreshTokenBundle: Name or service not known

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)%'

Categories