[NCP] Nextcloud check error

Hi, I have a raspberry pi 4 with a NCP image installed and nothing else. All automatic updates are enabled. It’s been working fine until day before yesterday. I’m getting a ‘internal server error’ when I go to the login site. Nextcloud check gives an error (datadir doesn’t exist) and after some time MariaDB goes down too (strangely not always…).
I found different and dated solutions in the forum but I didn’t wanted to apply them blindly, that’s why I opened a new topic. I’m sorry if I bloated the forum…

NextCloudPi version v1.20.1
NextCloudPi image NextCloudPi_07-21-19
distribution Raspbian GNU/Linux 10 \n \l
automount yes
USB devices none
datadir /media/USBdrive/ncdata (doesn’t exist)
rootfs usage 2.5G/29G
swapfile /var/swap
dbdir /var/lib/mysql
Nextcloud check error
HTTPD service up
PHP service up
MariaDB service up
Redis service up
Postfix service up
internet check ok
port check 80 open
port check 443 open
IP 192.168.178.148
gateway 192.168.178.1
interface eth0
certificates none
NAT loopback no
uptime 1:52

I appreciate if someone could help.

Your USBdrive seems to be disconnected!
Did you try to connect a second drive?
And also can you access your pi via ssh?
If so share output of:

ls -lh /media/

Thanks for the reply mate. I did have a second usbdrive for the database backups from beginning on, never had any problem with it. I just took it out and rebooted to try, it worked for a minute and then gave the same error again. I can access the device via ssh and NCP webui… ‘ls -lh /media/’ output is ‘total 0’ . Here is the ‘sudo ncp-report’ output if it helps:

NextCloudPi diagnostics

PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:02+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"JXNdTLXSIZXJePESaxv0","level":2,"time":"2020-01-25T19:15:02+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory \/media\/USBdrive\/ncdata\/tmp is not present or writable","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"file_get_contents(\/media\/USBdrive\/ncdata\/news\/config\/config.ini): failed to open stream: No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Files\/Storage\/Local.php#217","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"JXNdTLXSIZXJePESaxv0","level":2,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"news","method":"","url":"--","message":"Configuration invalid. Ignoring values.","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"mkdir(): Permission denied at \/var\/www\/nextcloud\/apps\/news\/lib\/AppInfo\/Application.php#142","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"JXNdTLXSIZXJePESaxv0","level":3,"time":"2020-01-25T19:15:03+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"chmod(): No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#86","userAgent":"--","version":"17.0.2.1"}
NextCloudPi version  v1.20.1
NextCloudPi image    NextCloudPi_07-21-19
distribution         Raspbian GNU/Linux 10 \n \l
automount            yes
USB devices          none
datadir              /media/USBdrive/ncdata (doesn't exist)
rootfs usage         2.6G/29G
swapfile             /var/swap
dbdir                /var/lib/mysql
Nextcloud check      error
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
Postfix service      up
internet check       ok
port check 80        open
port check 443       open
IP                   ***REMOVED SENSITIVE VALUE***
gateway              ***REMOVED SENSITIVE VALUE***
interface            eth0
certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
uptime               1min

Nextcloud configuration

PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:07+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"UoM2GUptAxDbwjeMODx6","level":2,"time":"2020-01-25T19:15:07+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory \/media\/USBdrive\/ncdata\/tmp is not present or writable","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"file_get_contents(\/media\/USBdrive\/ncdata\/news\/config\/config.ini): failed to open stream: No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Files\/Storage\/Local.php#217","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"UoM2GUptAxDbwjeMODx6","level":2,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"news","method":"","url":"--","message":"Configuration invalid. Ignoring values.","userAgent":"--","version":"17.0.2.1"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"mkdir(): Permission denied at \/var\/www\/nextcloud\/apps\/news\/lib\/AppInfo\/Application.php#142","userAgent":"--","version":"17.0.2.1"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/17/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /var/www/nextcloud/console.php(96): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 85
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#85","userAgent":"--","version":"17.0.2.1"}
{"reqId":"UoM2GUptAxDbwjeMODx6","level":3,"time":"2020-01-25T19:15:08+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"chmod(): No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#86","userAgent":"--","version":"17.0.2.1"}

HTTPd logs

[Sat Jan 25 19:14:23.908380 2020] [authz_host:error] [pid 842:tid 2755929120] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /js/minified.js failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:23.917017 2020] [authz_host:error] [pid 842:tid 2772730912] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /css/ncp.css failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:23.924974 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/ncp-logo.svg failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.038314 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/toggle.svg failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.043370 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/defaults.svg failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.057771 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/poweroff.svg failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.067508 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/reboot.svg failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.152874 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/poweroff.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.153191 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/dashboard.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.153659 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/search.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.155841 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/defaults-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.156167 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/nc-button.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.156536 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/settings-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.156864 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/info-white.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.157202 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/files.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.157530 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /img/wizard.svg failed, reason: unable to get the remote host name, referer: https://192.168.178.148:4443/css/ncp.css
[Sat Jan 25 19:14:24.169074 2020] [authz_host:error] [pid 842:tid 2781131808] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /ncp-output.php failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:24.211573 2020] [authz_host:error] [pid 842:tid 2772730912] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:29.716752 2020] [authz_host:error] [pid 842:tid 2772730912] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name
[Sat Jan 25 19:14:29.746482 2020] [authz_host:error] [pid 842:tid 2772730912] [client 192.168.178.114:48384] AH01753: access check of 'localhost' to /ncp-launcher.php failed, reason: unable to get the remote host name

Database logs

2020-01-25 19:14:10 0 [Note] InnoDB: Uses event mutexes
2020-01-25 19:14:10 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-01-25 19:14:10 0 [Note] InnoDB: Number of pools: 1
2020-01-25 19:14:10 0 [Note] InnoDB: Using generic crc32 instructions
2020-01-25 19:14:10 0 [Note] InnoDB: Initializing buffer pool, total size = 1.625G, instances = 1, chunk size = 128M
2020-01-25 19:14:10 0 [Note] InnoDB: Completed initialization of buffer pool
2020-01-25 19:14:10 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-01-25 19:14:11 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-01-25 19:14:11 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-01-25 19:14:11 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-01-25 19:14:11 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-01-25 19:14:11 0 [Note] InnoDB: 10.3.17 started; log sequence number 1725411767; transaction id 5415222
2020-01-25 19:14:11 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-01-25 19:14:11 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-01-25 19:14:11 0 [Note] Server socket created on IP: '127.0.0.1'.
2020-01-25 19:14:11 0 [Note] Reading of all Master_info entries succeeded
2020-01-25 19:14:11 0 [Note] Added new Master_info '' to hash table
2020-01-25 19:14:11 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.3.17-MariaDB-0+deb10u1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Raspbian 10
2020-01-25 19:14:13 0 [Note] InnoDB: Buffer pool(s) load completed at 200125 19:14:13

Nextcloud logs

tail: cannot open '/media/USBdrive/ncdata/nextcloud.log' for reading: No such file or directory

What is the output of

sudo ls -lh /var/www/nextcloud/

If your data directory is still in there, edit the config.php datadir value to point to it.

If you did not use nc-automount, how and where did you mount your external drive?

Here is the output:
total 144K
drwxr-x— 33 www-data www-data 4.0K Dec 19 08:51 3rdparty
drwxr-x— 60 www-data www-data 4.0K Jan 22 06:25 apps
-rw-r----- 1 www-data www-data 12K Dec 19 08:47 AUTHORS
drwxr-x— 2 www-data www-data 4.0K Jan 25 19:14 config
-rw-r----- 1 www-data www-data 3.8K Dec 19 08:47 console.php
-rw-r----- 1 www-data www-data 34K Dec 19 08:47 COPYING
drwxr-x— 23 www-data www-data 4.0K Dec 19 08:51 core
-rw-r----- 1 www-data www-data 4.9K Dec 19 08:47 cron.php
-rw-r----- 1 www-data www-data 156 Dec 19 08:47 index.html
-rw-r----- 1 www-data www-data 3.1K Dec 19 08:47 index.php
drwxr-x— 6 www-data www-data 4.0K Dec 19 08:47 lib
-rw-r----- 1 www-data www-data 283 Dec 19 08:47 occ
drwxr-x— 2 www-data www-data 4.0K Dec 19 08:47 ocm-provider
drwxr-x— 2 www-data www-data 4.0K Dec 19 08:47 ocs
drwxr-x— 2 www-data www-data 4.0K Dec 19 08:47 ocs-provider
-rw-r----- 1 www-data www-data 2.9K Dec 19 08:47 public.php
-rw-r----- 1 www-data www-data 5.1K Dec 19 08:47 remote.php
drwxr-x— 4 www-data www-data 4.0K Dec 19 08:47 resources
-rw-r----- 1 www-data www-data 26 Dec 19 08:47 robots.txt
drwxr-x— 13 www-data www-data 4.0K Dec 19 08:51 settings
-rw-r----- 1 www-data www-data 2.3K Dec 19 08:47 status.php
drwxr-x— 3 www-data www-data 4.0K Sep 2 13:48 themes
drwxr-x— 2 www-data www-data 4.0K Dec 19 08:48 updater
-rw-r----- 1 www-data www-data 362 Dec 19 08:51 version.php

As far as I can see, data directory is not there…

I did use nc-automount. It’s 1TB sata-drive attached to the Raspi 4 via USB.

Must have misunderstood about not using nc-automount…
Strange tho, /media/ total 0

What is output of

ls -lh /dev/disk/by-uuid/

and

df -h

total 0
lrwxrwxrwx 1 root root 15 Jan 25 19:13 8d008fde-f12a-47f7-8519-197ea707d3d4 -

…/…/mmcblk0p2
lrwxrwxrwx 1 root root 15 Jan 25 19:13 F661-303B → …/…/mmcblk0p1

Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 2.7G 25G 10% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 196M 1.8G 11% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 53M 200M 21% /boot
tmpfs 391M 0 391M 0% /run/user/1000

Its like the drive is not mounted at all… The drive is blinking like after ‘safely removed’

It probably was not removed safely or the drive is corrupt, you’ll have to try to connect it to another pc to try to fix it.
On Linux I use fsck

Ok, I’ll try. I bought a new drive just in case. If I copy paste the folder from the old drive to the new one, would it work? Or do I have to sync both drives somehow… ? Any with which tool would you do it on linux? Thanks alot for your help mate!

Hi @OliverV
fsck didn’t work because of the btrfs partition. I did a check and repair in gparted. And then cloned the old drive to the new one with ‘dd’
Plugged the new drive to the raspi, it worked for 10 minutes, after it started to give the same ‘Nextcloud check error’
I’m at a lost here…

there is btrfs-check, did you try it?

I did, no errors were found… It’s like the USB devices are safely removed after being automounted… I tried with a USB stick as well… lsusb shows nothing…
I have a instance backup, if i flash the NCP image to the sdcard again and restore from backup would it help? And how should I proceed with the data dir then?

Clearly my raspberry pi’s USB doesn’t work as expected anymore. I tried with usb stick as well, it loses power sometime after plugging in. I contacted the warranty service, lets see what happens. I ordered a Rock64 as a replacement. Thanks for the suggestions!

Continuing the discussion from [NCP] Nextcloud check error:

I am experiencing exactly the same issue. This happened after i installed the v1.20.7. Interestingly enough when typing in

ls -lh /media/

during boot-up it appears as if the drive is being mounted. Once the NCP is fooly booted it disappears.

On Raspberry Pi 4?
I’d first install another OS on a second sdcard and see if the problem persists…

Indeed the Raspberry Pi 4. I have tried exactly what you suggested. What I can report is that problem persists. I have tried it with three different drives, to ensure that it is not an issue caused by the HDD or SSD. What I have noticed though is that this is only caused by the USB 3 ports. There are absolutely no issues to report with the USB 2 ports.

I am having the same problem on a Raspberry Pi 4 using a USB 3 port.

The “internal server error” occurred and MariaDB went down.

I did a complete reinstall of the NCP image and less than a day later, I am getting the same error.

Maria DB is still up, but I am now getting the “Nextcloud check error.”

I will try it with a USB 2 port.

EDIT: switching to a USB 2 port brought Nextcloud back up. I will report back if it goes down again.

I tried with USB 2 ports and had the same problem unfortunately. Contacted the warranty service where i bought the Pi4 to get it checked but if you guys are having the same problem, it might be an problem caused by an update…

After a day or so, my NCP/Nextcloud instance crashed again. This is after moving the external drive to a USB 2 port (on a Pi4). The first time this happened, I could not access Nextcloud, but could still access the NCP page (:4443). This time I cannot access either one.

The Pi4 seems to be down entirely this time as I cannot ssh into it. I will reboot it and see how long it stays up.

This issue started with the most recent update.