mysql connection refused error message for a Laravel App using sqlite

Hi there,

new to Fly.io. My first deploy.

I have deployed a Laravel App. This App uses sqlite.
The app seems fine, but, as soon as I request something from the database, I get the following message:

{“message”:“SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select count() as aggregate from users where email = mymail@gmail.com)",“context”:{“exception”:{“class”:“Illuminate\Database\QueryException”,“message”:"SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select count() as aggregate from users where email = mymail@gmail.com)”,“code”:2002,“file”:“/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795”,“previous”:{“class”:“PDOException”,“message”:“SQLSTATE[HY000] [2002] Connection refused”,“code”:2002,“file”:“/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65”}}},“level”:400,“level_name”:“ERROR”,“channel”:“production”,“datetime”:“2023-08-11T08:38:35.601703+00:00”,“extra”:{}}

Why is it trying to connect to a mySQL database? What’s wrong? How can I fix it?

Thanks in advance,
Javier

Update

I have found the docs for Fly.io & Laravel & SQLite. I got this far:

2023-08-11T09:04:38Z app[5683074f72d0d8] ams [info]{"message":"Database file at path [/var/www/html/storage/database/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)","context":{"exception":{"class":"Illuminate\\Database\\QueryException","message":"Database file at path [/var/www/html/storage/database/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)","code":0,"file":"/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795","previous":{"class":"Illuminate\\Database\\SQLiteDatabaseDoesNotExistException","message":"Database file at path [/var/www/html/storage/database/database.sqlite] does not exist. Ensure this is an absolute path to the database.","code":0,"file":"/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:34"}}},"level":400,"level_name":"ERROR","channel":"production","datetime":"2023-08-11T09:04:38.740856+00:00","

I keep investigating and trying, but decided to log it here for others.

Alright. I got so far that I get no errors anymore. The DB seems not to be updating, but not connection errors anymore.

I modified the env tag value from the fly.toml file:
before:
DB_DATABASE=“/var/www/html/storage/database/database.sqlite”
after:
DB_DATABASE=“/var/www/html/database/database.sqlite”

I had previously followed the docs regarding the creation of a storage volume.

I hope this helps.

1 Like

Alright. Tested the DB and it seems to work. New registers are being added.

Happily closed!