Nextcloud Cron suddenly is giving an error

Nextcloud version (eg, 20.0.5): 26.0.3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.57
PHP version (eg, 7.4): PHP 8.1.20

The issue you are facing:

Let me say that there is a forum entry for a similar error, but it is not the same, and the solution that is suggested also does not work for me. For most posts, I see blame SQL, but I had it checked, and all seem to work correctly with the DB. So, I am not sure what else it could be, so I wanted to find out who maybe had the same issue and solved it. I must also mention that I have run this server for 2 years without issues; the issue arose a few weeks back.

For a few weeks, I have had the issue that the cron.php gives the following error:

root@mailapp:~# sudo -u ebm /usr/bin/php8.1 -f /home/www/public_html/ebm/NextCloud/cron.php
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /home/www/public_html/ebm/NextCloud/lib/private/DB/Connection.php:140
Stack trace:
#0 /home/www/public_html/ebm/NextCloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /home/www/public_html/ebm/NextCloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /home/www/public_html/ebm/NextCloud/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery()
#3 /home/www/public_html/ebm/NextCloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /home/www/public_html/ebm/NextCloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /home/www/public_html/ebm/NextCloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /home/www/public_html/ebm/NextCloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /home/www/public_html/ebm/NextCloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /home/www/public_html/ebm/NextCloud/lib/private/legacy/OC_App.php(976): OC\AppConfig->getValues()
#9 /home/www/public_html/ebm/NextCloud/lib/private/Server.php(731): OC_App::getAppVersions()
#10 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#11 /home/www/public_html/ebm/NextCloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#12 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /home/www/public_html/ebm/NextCloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#15 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#17 /home/www/public_html/ebm/NextCloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#18 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /home/www/public_html/ebm/NextCloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#21 /home/www/public_html/ebm/NextCloud/lib/private/Server.php(1112): OC\AppFramework\Utility\SimpleContainer->get()
#22 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#23 /home/www/public_html/ebm/NextCloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#24 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /home/www/public_html/ebm/NextCloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#27 /home/www/public_html/ebm/NextCloud/lib/private/Server.php(2067): OC\AppFramework\Utility\SimpleContainer->get()
#28 /home/www/public_html/ebm/NextCloud/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /home/www/public_html/ebm/NextCloud/lib/private/Server.php(465): OC\Files\View->__construct()
#30 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#31 /home/www/public_html/ebm/NextCloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#32 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#33 /home/www/public_html/ebm/NextCloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /home/www/public_html/ebm/NextCloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#35 /home/www/public_html/ebm/NextCloud/lib/private/Server.php(1469): OC\AppFramework\Utility\SimpleContainer->get()
#36 /home/www/public_html/ebm/NextCloud/lib/base.php(627): OC\Server->boot()
#37 /home/www/public_html/ebm/NextCloud/lib/base.php(1169): OC::init()
#38 /home/www/public_html/ebm/NextCloud/cron.php(43): require_once(‘…’)
#39 {main}

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Not sure

The output of your Nextcloud log in Admin > Logging:


The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php $CONFIG = array ( 'instanceid' => 'oct5oaviw70a', 'passwordsalt' => 'glp1fiqs5dvd8dxexwgofiapl9y8mq', 'secret' => 'gn54gh6ibgnz4qzw5qot7atqetsl1l6fnbr5iimavtpi0cwz', 'trusted_domains' => array ( 0 => '', ), 'datadirectory' => '/data', 'dbtype' => 'mysql', 'version' => '', 'overwrite.cli.url' => '', 'dbname' => 'next481', 'dbhost' => 'localhost', 'dbport' => '3306', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'next481', 'dbpassword' => '***********', 'installed' => true, 'default_phone_region' => 'MY', 'mail_smtpmode' => 'smtp', 'mail_sendmailmode' => 'smtp', 'mail_from_address' => 'server', 'mail_domain' => '', 'mail_smtpauthtype' => 'PLAIN', 'mail_smtpauth' => 1, 'mail_smtphost' => '', 'mail_smtpport' => '587', 'mail_smtpname' => '', 'mail_smtppassword' => '******', 'theme' => '', 'loglevel' => 0, 'maintenance' => false, 'app_install_overwrite' => array ( 0 => 'duplicatefinder', 1 => 'groupfolders', 2 => 'passwords', 3 => 'admin_notifications', 4 => 'impersonate', ), 'updater.secret' => '$2y$10$DF*******************TdPAYWLT4/O', ); The output of your Apache/nginx/system log in `/var/log/____`: ``` PASTE HERE ``` PASTE HERE ``` Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary. PASTE HERE ```
1 Like

What changes did you make before the issue started? Also, did you try following the solution from the other topics you found related to this issue?

The only thing that happened on the system was a minor upgrade of PHP8.1x that happened with apt.
In addition, I updated nextcloud using the web interface from 26.0.1 to 26.0.3. This happened without errors or issues.

In most of the posts, they say it is a DB issue, but the MariaDB is running, and also, some other websites I have that use the DB are running fine. Also, PhpMyAdmin is working fine.

I also restarted the system and SQL, and all is running fine.

Other than this, I do not really find anything I could be troubleshooting. My server is maintained using the WEBUZO admin. As I have a support contract with them, I also asked them to check the SQL installation, and they also insist that all is installed right. Also, it makes sense because the CRON was always working without issues.

Therefore, I am a bit stuck because the corn for NextCloud is quite important to ensure all is running as desired. Any ideas that I could try would be very welcome.

Thank you all for thinking about the issue and maybe giving some tips on what I could try to resolve this.

Sounds like you has the same issue as this one:

Does that mean you had already purged php and reinstalled it with all the modules?

@FadeFx - I will have to look into this. My Unmanaged VPS is from A2Hosting and uses a MultiPHP environment. It uses WEBUZO as the admin system. So, it is not exactly straightforward to recompile PHP. But I will try this and see what happens.

@Kerasit - Thanks, I did not see this, I will try to have PHP reinstalled. But I did try to run the CRON manually in the command prompt and used PHP 7.4, 8.0 and 8.1 and all give the same error.

We still might suffer from a product issue, did you find a solution yet?

Here is a little update.
I reinstalled PHP8.1 and also installed PHP8.2 (My system is a multi-PHP FPM configuration). All were compiled fine and all my WordPress and other APPs work fine. In general, NextCloud works in the web admin. However, the cron still gives the same error when executed in the command prompt. I did also set the domain to 8.2 and tried to execute the cron with PHP8.2 but the same error. Also in the Admin, it gives a message that the cron did not run for 2 months.
So basically, after recompiling everything I am back on square one. I’m not sure if you have any other ideas on how I could troubleshoot this further.

It all looks pretty chaotic. On the one hand php managed by apt and on the other hand self-compiled multi-php-version installations.

You should give more and better information, and please use the correct markdown syntax for that in future, specialy for log outputs which should be placed in Fenced Codeblocks, so that one can read and work with it (also use the preview window on the right side for that if everything looks good).

As far as I understood are you using php8.1 with fpm, so please could you give the output of:

php8.1 -m | grep my
php-fpm8.1 -m | grep my

and if these match, then the somewhat more detailed variant:

php8.1 -i | grep my
php-fpm8.1 -i | grep my

Ok, so i solved my problem now, it seems i was using partially php8.1 and partially php 8.2, php 8.1 had fpm installed and 8.2 did not, there was no fpm folder in there. Actually i did not check at first, but

sudo php -v

gave php 8.2 so what i did now is switch to 8.1 via

sudo update-alternatives --config php


php -c /etc/php/apache2/php.ini -v
already gives me php 8.1 as used version in apache2 which makes me think of using different version of php in apache than in cli, which is why cron jobs were not working but webinterface does.

And now all is fixed, happy camper…

1 Like

That was exactly my guess as well. One of the most common sources of error with PHP at all.

Glad you solved it.

Much luck!

1 Like

Still i think there might be something wrong with opcache, i would loke to remove 8.2 completely, i wanted to try and install

sudo apt install php8.1 php-opcache

but this also installed stuff for php 8.2 probably i am holding it wrong?

I woukd like to remove php8.2 completely from the system, but it claims php8.2 is not installed…

@ernolf, thanks for the response.
It seems that it was the same issue as described by @FadeFx a different version of PHP ran the corn. It is working now after I ensured that it uses the same path as the PHP that is assigned to this domain.

Just for your info, it is not compiled manually. All is done by APT but not in the terminal but by WEBUZO, which is the server admin software I use on this system. Anyway, the corn is running g now, but I have a huge other problem for wish I will create a new post.

Files do not display in web after DB restore - :information_source: Support - Nextcloud community

php8.1 -i | grep my

Additional .ini files parsed => /etc/php/8.1/cli/conf.d/10-mysqlnd.ini,
Client API library version => mysqlnd 8.1.21
mysqli.allow_local_infile => Off => Off
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysqli.default_user => no value => no value
mysqli.local_infile_directory => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
mysqlnd => enabled
Version => mysqlnd 8.1.21
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_caching_sha2_password,auth_plugin_sha256_password
API Extensions => mysqli,pdo_mysql
PDO drivers => mysql
Client API version => mysqlnd 8.1.21
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

Please msrk thst topic as fixed and my post as solution for others running into the same issue…