# Nextcloud Cron suddenly is giving an error

**URL:** <https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494>\
**Category:** ℹ️ Support\
**Created:** [July 4, 2023, 8:38am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494 "2023-07-04T08:38:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasB](https://help.nextcloud.com/letter_avatar/thomasb/32/5_5575768a8748004e209b776fc1b2916d.png) [@ThomasB](https://help.nextcloud.com/u/ThomasB)\
**Post date:** [July 4, 2023, 8:38am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/1 "2023-07-04T08:38:32Z")

</div>

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:  
Hi,

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}  
root@mailapp:~#

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

Steps to replicate it:

1. Not sure
2. 
3. 

The output of your Nextcloud log in **Admin \> Logging** :

```auto
PASTE HERE

```

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

```auto
PASTE HERE

```

\<?php $CONFIG = array ( 'instanceid' =\> 'oct5oaviw70a', 'passwordsalt' =\> 'glp1fiqs5dvd8dxexwgofiapl9y8mq', 'secret' =\> 'gn54gh6ibgnz4qzw5qot7atqetsl1l6fnbr5iimavtpi0cwz', 'trusted\_domains' =\> array ( 0 =\> 'mydomain.com', ), 'datadirectory' =\> '/data', 'dbtype' =\> 'mysql', 'version' =\> '26.0.3.2', 'overwrite.cli.url' =\> 'https://mydomain.com/NextCloud', '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' =\> 'mydomain.com', 'mail\_smtpauthtype' =\> 'PLAIN', 'mail\_smtpauth' =\> 1, 'mail\_smtphost' =\> 'mail.mydomain.net', 'mail\_smtpport' =\> '587', 'mail\_smtpname' =\> 'mail@mydomain.com', '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 ```

---

<div class="post-metadata">

**Author:** ![Irdi](https://help.nextcloud.com/user_avatar/help.nextcloud.com/irdi/32/50042_2.png) [@Irdi](https://help.nextcloud.com/u/Irdi)\
**Post date:** [July 4, 2023, 9:34am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/2 "2023-07-04T09:34:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ThomasB](https://help.nextcloud.com/letter_avatar/thomasb/32/5_5575768a8748004e209b776fc1b2916d.png) [@ThomasB](https://help.nextcloud.com/u/ThomasB)\
**Post date:** [July 5, 2023, 5:07am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/3 "2023-07-05T05:07:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kerasit](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kerasit/32/78080_2.png) [@Kerasit](https://help.nextcloud.com/u/Kerasit)\
**Post date:** [July 5, 2023, 8:50am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/4 "2023-07-05T08:50:53Z")

</div>

Sounds like you has the same issue as this one:

> [@Purge and reinstall PHP](https://help.nextcloud.com/t/purge-and-reinstall-php/165479):
>
> Hi, after going through some troubles during the upgrade process from NC 25.0.3, probably partially caused by a defect sdcard, to NC26.0.1 i have now managed to do a fresh install of Nextcloud on a new card and restore my last Backup of NC 25.0.3 and then update it to NC 26.0.1 i have now a working instance except that cron.php is not working. I have read that i need to reinstall PHP and indeed i have now PHP 8.1 and 8.2 on the system. I would like to clean remove PHP and reinstall the version t…

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 5, 2023, 5:25pm UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/5 "2023-07-05T17:25:45Z")

</div>

> [@ThomasB](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![ThomasB](https://help.nextcloud.com/letter_avatar/thomasb/32/5_5575768a8748004e209b776fc1b2916d.png) [@ThomasB](https://help.nextcloud.com/u/ThomasB)\
**Post date:** [July 6, 2023, 7:35am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/6 "2023-07-06T07:35:26Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 8, 2023, 4:34am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/7 "2023-07-08T04:34:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ThomasB](https://help.nextcloud.com/letter_avatar/thomasb/32/5_5575768a8748004e209b776fc1b2916d.png) [@ThomasB](https://help.nextcloud.com/u/ThomasB)\
**Post date:** [July 8, 2023, 5:06am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/8 "2023-07-08T05:06:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [July 8, 2023, 10:18am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/9 "2023-07-08T10:18:52Z")

</div>

> [@ThomasB](#):
>
> The only thing that happened on the system was a minor upgrade of PHP8.1x that happened with apt.

> [@ThomasB](#):
>
> I reinstalled PHP8.1 and also installed PHP8.2 (My system is a multi-PHP FPM configuration). All were compiled fine

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](https://www.markdownguide.org/cheat-sheet) for that in future, specialy for log outputs which should be placed in [Fenced Codeblocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks), 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:

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

```

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

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

```

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 9, 2023, 6:40am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/10 "2023-07-09T06:40:04Z")

</div>

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

However

> 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…

---

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [July 9, 2023, 8:59am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/11 "2023-07-09T08:59:06Z")

</div>

> [@FadeFx](#):
>
> i was using partially php8.1 and partially php 8.2

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

> [@FadeFx](#):
>
> And now all is fixed

Glad you solved it.

Much luck!

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 9, 2023, 12:17pm UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/12 "2023-07-09T12:17:15Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ThomasB](https://help.nextcloud.com/letter_avatar/thomasb/32/5_5575768a8748004e209b776fc1b2916d.png) [@ThomasB](https://help.nextcloud.com/u/ThomasB)\
**Post date:** [July 10, 2023, 8:21am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/13 "2023-07-10T08:21:49Z")

</div>

@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 - ℹ Support - Nextcloud community](https://help.nextcloud.com/t/files-do-not-display-in-web-after-db-restore/165887)

# php8.1 -i | grep my

Additional .ini files parsed =\> /etc/php/8.1/cli/conf.d/10-mysqlnd.ini,  
/etc/php/8.1/cli/conf.d/20-mysqli.ini,  
/etc/php/8.1/cli/conf.d/20-pdo\_mysql.ini,  
mysqli  
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  
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  
pdo\_mysql  
Client API version =\> mysqlnd 8.1.21  
pdo\_mysql.default\_socket =\> /var/run/mysqld/mysqld.sock =\> /var/run/mysqld/mysqld.sock  
root

---

<div class="post-metadata">

**Author:** ![FadeFx](https://help.nextcloud.com/user_avatar/help.nextcloud.com/fadefx/32/9921_2.png) [@FadeFx](https://help.nextcloud.com/u/FadeFx)\
**Post date:** [July 10, 2023, 10:31am UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/14 "2023-07-10T10:31:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 14, 2024, 12:42pm UTC](https://help.nextcloud.com/t/nextcloud-cron-suddenly-is-giving-an-error/165494/15 "2024-12-14T12:42:24Z")

</div>


