Unhandled exception has been thrown

Nextcloud version (eg, 12.0.2): 15.0.5
Operating system and version (eg, Ubuntu 17.04): Ubuntu 18.10
Apache or nginx version (eg, Apache 2.4.25): nginx 1.15.5
PHP version (eg, 7.1): 7.2

The issue you are facing: When I ran “sudo php occ user:report” I got the following error:

An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:64

Is this the first time you’ve seen this error? (Y/N): Yes, but I don’t think it’s the first time it’s happened. I’ve been getting errors when I try to log in for some time.

Please check the forum for related requests. This question has already been asked and answered several times and is most likely caused by a missing php module for your database. It need to be loaded by your system to allow to access the Nextcloud database.