Hi guys,
i’m having problem with the background cron jobs. After searching and trying for a couple of days, i still haven’t find a solution for my particular problem. So, you are my last resort
Background info:
I recently switched for the background jobs from Ajax to cron (hadn’t seen, that this is the recommended option). I switched this option in the nextcloud Web frontend as well as in the # crontab settings. Since then, i get the error view in the frontend that something is not working.
To get a better idea, i tried manually triggering cron with the following:
php -f /media/nextcloud/html/cron.php --define apc.enable_cli=1
After a couple of seconds, i get the following:
pi@raspi:/media/nextcloud/html $ sudo php -f /media/nextcloud/html/cron.php --define apc.enable_cli=1
{“reqId”:“iGzJSzgY1veDYl1o9E6a”,“level”:3,“time”:“2025-01-07T09:52:24+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“cron”,“method”:“”,“url”:“–”,“message”:“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for nextcloud_db failed: Name or service not known”,“userAgent”:“–”,“version”:“30.0.4.1”,“exception”:{“Exception”:“Doctrine\DBAL\Exception”,“Message”:“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for nextcloud_db failed: Name or service not known”,“Code”:2002,“Trace”:[{“file”:“/media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php”,“line”:453,“function”:“connect”,“class”:“OC\DB\Connection”,“type”:“->”},{“file”:“/media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php”,“line”:411,“function”:“getDatabasePlatformVersion”,“class”:“Doctrine\DBAL\Connection”,“type”:“->”},{“file”:“/media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php”,“line”:318,“function”:“detectDatabasePlatform”,“class”:“Doctrine\DBAL\Connection”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/DB/Connection.php”,“line”:899,“function”:“getDatabasePlatform”,“class”:“Doctrine\DBAL\Connection”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/DB/ConnectionAdapter.php”,“line”:235,“function”:“getDatabaseProvider”,“class”:“OC\DB\Connection”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/DB/QueryBuilder/QueryBuilder.php”,“line”:96,“function”:“getDatabaseProvider”,“class”:“OC\DB\ConnectionAdapter”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/AppConfig.php”,“line”:1211,“function”:“expr”,“class”:“OC\DB\QueryBuilder\QueryBuilder”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/AppConfig.php”,“line”:237,“function”:“loadConfig”,“class”:“OC\AppConfig”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/AppConfig.php”,“line”:1351,“function”:“searchValues”,“class”:“OC\AppConfig”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/App/AppManager.php”,“line”:126,“function”:“getValues”,“class”:“OC\AppConfig”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/App/AppManager.php”,“line”:147,“function”:“getInstalledAppsValues”,“class”:“OC\App\AppManager”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/legacy/OC_App.php”,“line”:191,“function”:“getInstalledApps”,“class”:“OC\App\AppManager”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/private/AppFramework/Bootstrap/Coordinator.php”,“line”:48,“function”:“getEnabledApps”,“class”:“OC_App”,“type”:“::”},{“file”:“/media/nextcloud/html/lib/base.php”,“line”:659,“function”:“runInitialRegistration”,“class”:“OC\AppFramework\Bootstrap\Coordinator”,“type”:“->”},{“file”:“/media/nextcloud/html/lib/base.php”,“line”:1134,“function”:“init”,“class”:“OC”,“type”:“::”},{“file”:“/media/nextcloud/html/cron.php”,“line”:24,“args”:[“/media/nextcloud/html/lib/base.php”],“function”:“require_once”}],“File”:“/media/nextcloud/html/lib/private/DB/Connection.php”,“Line”:233,“message”:“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for nextcloud_db failed: Name or service not known”,“exception”:{},“CustomMessage”:“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for nextcloud_db failed: Name or service not known”}}
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for nextcloud_db failed: Name or service not known in /media/nextcloud/html/lib/private/DB/Connection.php:233
Stack trace:
#0 /media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /media/nextcloud/html/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /media/nextcloud/html/lib/private/DB/Connection.php(899): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /media/nextcloud/html/lib/private/DB/ConnectionAdapter.php(235): OC\DB\Connection->getDatabaseProvider()
#5 /media/nextcloud/html/lib/private/DB/QueryBuilder/QueryBuilder.php(96): OC\DB\ConnectionAdapter->getDatabaseProvider()
#6 /media/nextcloud/html/lib/private/AppConfig.php(1211): OC\DB\QueryBuilder\QueryBuilder->expr()
#7 /media/nextcloud/html/lib/private/AppConfig.php(237): OC\AppConfig->loadConfig()
#8 /media/nextcloud/html/lib/private/AppConfig.php(1351): OC\AppConfig->searchValues()
#9 /media/nextcloud/html/lib/private/App/AppManager.php(126): OC\AppConfig->getValues()
#10 /media/nextcloud/html/lib/private/App/AppManager.php(147): OC\App\AppManager->getInstalledAppsValues()
#11 /media/nextcloud/html/lib/private/legacy/OC_App.php(191): OC\App\AppManager->getInstalledApps()
#12 /media/nextcloud/html/lib/private/AppFramework/Bootstrap/Coordinator.php(48): OC_App::getEnabledApps()
#13 /media/nextcloud/html/lib/base.php(659): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#14 /media/nextcloud/html/lib/base.php(1134): OC::init()
#15 /media/nextcloud/html/cron.php(24): require_once(‘…’)
#16 {main}
This looks like a problem with the database, but my nextcloud is running for month without problems.
My nextcloud is on version 30.0.04.
It runs in a docker container on a raspberry pi 5.
As a proxy, i use traefik.
For further context, this is my docker compose file:
version: “3.8”
services:
nextcloud:
image: nextcloud:latest
container_name: nextcloud
ports:
- 4646:80
labels:
- traefik.docker.network= traefik_web
- traefik.enable=true
- traefik.http.routers.nextcloud.entrypoints=https
- traefik.http.routers.nextcloud.rule=Host(<my.domain>
)
- traefik.http.middlewares.nextcloud.headers.stsSeconds=15552000
- traefik.http.middlewares.nextcloud.headers.stsPreload=true
- traefik.http.middlewares.nextcloud_redirect.redirectregex.permanent=true
- traefik.http.middlewares.nextcloud_redirect.redirectregex.regex=^https://(.*)/.well-known/(card|cal)dav
- traefik.http.middlewares.nextcloud_redirect.redirectregex.replacement=https://$${1}/remote.php/dav/
volumes:
- /media/nextcloud/html:/var/www/html
restart: unless-stopped
environment:
- MYSQL_HOST=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=
- MYSQL_USER=
- TRUSTED_PROXIES=
depends_on:
- nextcloud_db
links:
- nextcloud_db
networks:
- traefik_web
#- nextcloud
logging:
options:
max-size: 5m
max-file: “3”
nextcloud_db:
image: yobasystems/alpine-mariadb
container_name: nextcloud_db
volumes:
- /media/nextcloud/db:/var/lib/mysql
restart: unless-stopped
environment:
- MYSQL_HOST=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=
- MYSQL_USER=
- TRUSTED_PROXIES=
- MYSQL_ROOT_PASSWORD=
networks:
- traefik_web
logging:
options:
max-size: 5m
max-file: “3”
networks:
traefik_web:
external: true
I checked the obvious one: The environment variables are the same in the config.php. But as i mentioned, the database in general works.
Do you have any idea? What am i missing?
Thanks in advance!