My nextcloud instance quit working a few weeks ago with a 504 error. In troubleshooting, I rebuilt my stack, and now I get an “Internal Server Error” webpage when I try to connect to nextcloud. When trying to connect through the command line, I get:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Host is unreachable
I am running:
NUC7i7BNH w/4 CPU cores and 32GB memory
Fedora 32 installed on an SSD.
Docker v20.10.6 Build 370c289
SWAG Container
Nextcloud Container
MariaDB Container
Redis Container
Here is my docker-compose.yml:
version: "2.1"
services:
swag_proxy:
image: ghcr.io/linuxserver/swag
container_name: swag_proxy
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Budapest
- URL=mynextcloud.com
- SUBDOMAINS=www,nc
- VALIDATION=http
- DHLEVEL=2048 #optional
- ONLY_SUBDOMAINS=false #optional
volumes:
- ./config:/config
ports:
- 443:443
- 80:80 #optional
restart: unless-stopped
networks:
BACKBONE:
nextcloud:
image: ghcr.io/linuxserver/nextcloud:php8
container_name: my_nextcloud
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Budapest
volumes:
- ./config:/config
- ./data:/data
ports:
- 8200:80
- 4432:443
restart: unless-stopped
networks:
net1:
BACKBONE:
mariadb:
image: ghcr.io/linuxserver/mariadb:alpine
container_name: my_mariadb
environment:
- PUID=1000
- PGID=1000
- MYSQL_ROOT_PASSWORD=mysqlrootpassword
- TZ=Europe/Budapest
- MYSQL_DATABASE=nextcloud # Optional
- MYSQL_USER=nextclouduser #Optional
- MYSQL_PASSWORD=nextcloudpassword #Optional
volumes:
- ./dbconfig:/config
restart: unless-stopped
networks:
net1:
redis:
image: redis:latest
container_name: my_redis
command: redis-server --appendonly yes --appendfsync everysec
volumes:
- ./redisconfig/data:/data
restart: unless-stopped
networks:
net1:
networks:
net1:
internal: true
BACKBONE:
external:
name: BACKBONE_network
My config.php:
<?php
$CONFIG = array (
'instanceid' => 'randominstanceid',
'passwordsalt' => 'salt',
'trusted_domains' =>
array (
0 => 'nc.mynextcloud.com',
1 => 'localhost',
),
'datadirectory' => '/data',
'version' => '21.0.1.1',
'dbtype' => 'mysql',
'dbhost' => 'my_mariadb:3306',
# 'dbhost' => 'localhost',
'dbport' => '',
'dbname' => 'nextcloud',
'dbuser' => 'nextclouduser',
'dbpassword' => 'nextcloudpassword',
'dbtableprefix' => 'oc_',
'installed' => true,
'overwritehost' => 'nc.mynextcloud.com',
'overwriteprotocol' => 'https',
'overwrite.cli.url' => 'https://nc.mynextcloud.com',
'updater.release.channel' => 'stable',
'loglevel' => 2,
'logtimezone' => 'Europe/Budapest',
'preview_max_x' => 4096,
'preview_max_y' => 4096,
'preview_max_filesize_image' => 50,
'enabledPreviewProviders' =>
array (
0 => 'OC\\Preview\\PNG',
1 => 'OC\\Preview\\JPEG',
2 => 'OC\\Preview\\GIF',
3 => 'OC\\Preview\\HEIC',
4 => 'OC\\Preview\\BMP',
5 => 'OC\\Preview\\XBitmap',
6 => 'OC\\Preview\\MP3',
7 => 'OC\\Preview\\TXT',
8 => 'OC\\Preview\\MarkDown',
9 => 'OC\\Preview\\OpenDocument',
10 => 'OC\\Preview\\Krita',
),
'maintenance' => false,
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'my_redis',
'port' => 6379,
'timeout' => 0.0,
),
'mysql.utf8mb4' => true,
'theme' => '',
'secret' => 'SECRET',
'trusted_proxies' =>
array (
0 => 'swag_proxy',
),
'max_filesize_animated_gifs_public_sharing' => 20,
'app_install_overwrite' =>
array (
0 => 'rainloop',
),
);
MariaDB Error log:
210424 15:28:16 mysqld_safe Starting mariadbd daemon with databases from /config/databases
2021-04-24 15:28:16 0 [Note] /usr/bin/mariadbd (mysqld 10.5.9-MariaDB-log) starting as process 479 ...
2021-04-24 15:28:16 0 [Note] InnoDB: Uses event mutexes
2021-04-24 15:28:16 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-04-24 15:28:16 0 [Note] InnoDB: Number of pools: 1
2021-04-24 15:28:16 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2021-04-24 15:28:16 0 [Note] mariadbd: O_TMPFILE is not supported on /var/tmp (disabling future attempts)
2021-04-24 15:28:16 0 [Note] InnoDB: Using Linux native AIO
2021-04-24 15:28:16 0 [Note] InnoDB: Initializing buffer pool, total size = 268435456, chunk size = 134217728
2021-04-24 15:28:16 0 [Note] InnoDB: Completed initialization of buffer pool
2021-04-24 15:28:16 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-04-24 15:28:16 0 [Note] InnoDB: 128 rollback segments are active.
2021-04-24 15:28:16 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-04-24 15:28:16 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-04-24 15:28:16 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-04-24 15:28:16 0 [Note] InnoDB: 10.5.9 started; log sequence number 352851685; transaction id 1144
2021-04-24 15:28:16 0 [Note] InnoDB: Loading buffer pool(s) from /config/databases/ib_buffer_pool
2021-04-24 15:28:16 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-04-24 15:28:17 0 [Note] Server socket created on IP: '::'.
2021-04-24 15:28:17 0 [Note] Reading of all Master_info entries succeeded
2021-04-24 15:28:17 0 [Note] Added new Master_info '' to hash table
2021-04-24 15:28:17 0 [Note] /usr/bin/mariadbd: ready for connections.
Version: '10.5.9-MariaDB-log' socket: '/run/mysqld/mysqld.sock' port: 3306 MariaDB Server
2021-04-24 15:28:18 0 [Note] InnoDB: Buffer pool(s) load completed at 210424 15:28:18
MariaDB container startup log:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing...
-------------------------------------
_ ()
| | ___ _ __
| | / __| | | / \
| | \__ \ | | | () |
|_| |___/ |_| \__/
Brought to you by linuxserver.io
-------------------------------------
To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------
User uid: 1000
User gid: 1000
-------------------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
[cont-init.d] 30-config: exited 0.
[cont-init.d] 40-initialise-db: executing...
[cont-init.d] 40-initialise-db: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
210424 16:25:19 mysqld_safe Logging to '/config/databases/0111c175299d.err'.
210424 16:25:19 mysqld_safe Starting mariadbd daemon with databases from /config/databases
Nextcloud container startup log:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing...
-------------------------------------
_ ()
| | ___ _ __
| | / __| | | / \
| | \__ \ | | | () |
|_| |___/ |_| \__/
Brought to you by linuxserver.io
-------------------------------------
To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------
User uid: 1000
User gid: 1000
-------------------------------------
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] 50-install: executing...
[cont-init.d] 50-install: exited 0.
[cont-init.d] 60-memcache: executing...
[cont-init.d] 60-memcache: exited 0.
[cont-init.d] 70-aliases: executing...
[cont-init.d] 70-aliases: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Proxy conf from Swag_proxy:
## Version 2020/12/09
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name nc.mynextcloud.com;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
include /config/nginx/proxy.conf;
resolver 127.0.0.11 valid=30s;
set $upstream_app my_nextcloud;
set $upstream_port 443;
set $upstream_proto https;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_max_temp_file_size 2048m;
}
}
When I run this command:
docker exec -u abc my_nextcloud php8 /config/www/nextcloud/occ user:list
I get an error
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Host is unreachable in /config/www/nextcloud/lib/private/DB/Connection.php:85
I believe the problem may be something to do with this MariaDB image defaulting to a Unix socket instead of TCP? I’ve tried several settings, but cannot get the above command to work in order to confirm I can access the database from my nextcloud container.
Any help with this will be appreciated.