Your software
My Mautic version is: 3.1.0
My PHP version is: 7.3.25
My Database type and version is: Mysql 5.7
Your problem
My problem is: cron jobs fail.
These errors are showing in the log:
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
Steps I have tried to fix the problem:
Cron jobs work when run with sudo, but fail with www-data user. I’ve checked all files and folders have user and group set to www-data. All directories are 755 and files are 644.
I am having the same issue and can’t figure out the reason for this. My cron jobs are just not able to connect to mysql when running with “sudo -u”, neither with root nor with www-data. As you described when running without “sudo -u” it works.
Hi, I finally found out what the problem was. I was running Mautic in a Docker container which connected to the DB on the host system. When I set up Mautic I may have used an internal Docker IP to connect the application to the DB and I suspect that at that time the IP address was written into app/config/local.php. Later I changed the host to “host.docker.internal” but that was not applied in local.php. So I just set that name instead of the IP address and it started working.
If anyone knows why the settings from local.php only apply to cron jobs (and the command with “sudo -u”) please let me know, it would be great to have an explanation for this weird behaviour.