I deployed Laravel app on infinityfree.com and I get this error:
SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select * from sessions where id = xKNBtRsZTlb7lTyTuuTpYJvoLcsWkCaLkHAcAaay limit 1)
My database is imported from local phpmyadmin.
I changed my .env file to match my new database credentials and I guarantee that they are correct.
APP_NAME=AnswerFinder
APP_ENV=production
APP_KEY=base64:K5XZh3UywToemqlEPwbF3X0R7KMlHkxjzbkTjGo7REs=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=https://my infinityfree url
DB_CONNECTION=mysql
DB_HOST=sql303.infinityfree.com
DB_PORT=3306
DB_DATABASE= my infinityfree db name
DB_USERNAME= my infinityfree db username
DB_PASSWORD= my infinityfree pw
My config/database.php file:
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'Albatraoz01'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
My file structure in infinityfree looks like this:
- /htdocs
- /answerfinder (folder containing all the files from my project except public folder)
- files from public folder
I have uploaded Laravel 7 and Laravel 8 apps likes this so I don't really know what the problem is now.
This is Laravel 11 app so they might have changed something.
I would like to mention that because this is free hosting, I don't have terminal and every change has to be done locally and then uploaded with FileZilla again or using some php script.