Can't run occ-Commands

I have installed a new nextcloud-server. Everything works fine with one exeption: I can’t run any occ-Command from the comand-line. It gives the message "An unhandled exception has been thrown: Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory in /httpdocs/nextcloud/lib/private/DB/Connection.php:72
The webbased updater works, I can add users and files, so the connection to the database should be working. I tried the occ-command db:add-missing-indices and the occ-command maintenance:mode both times with the same result.
In the installation-process something strange happened: The webbased installation-process went well. At the end, when starting the installation of recommended apps, the browser showed an unvalid URL: https:///index.php/core/apps/recommended. The Adress of my Server was missing. I added the adress, and the Installtion of the recommended apps finished. I already restartet the installation from scratch, always with the same result. Has anybody a suggestion what to do?

Nextcloud Vers. 20.0.9, Linux-Server Redhat, PHP vers. 7.4, MySQL

On a web server you will usually find PHP in two flavors, the PHP web component and the PHP CLI component.

If you can access Nextcloud using a web browser, the PHP web component has most likely been configured correctly.

To be able to use the occ component, the PHP CLI component need to be configured too. In your case the error message indicates that the database access hasn’t been correctly configured.

So first check and post the database configuration from the Nextcloud config.php file.
Next make sure that the database module is correctly loaded (php -m).

1 Like

Thanks for your answer. With the help of my provider I could solve the problem. On this server, the database is not accessible via localhost when you work with SSH. I had to change the adress to 127.0.0.1 to get the connection The second problem was the address of the data folder. I had to create a symlink to get access to the data-folder via ssh.

1 Like

Would you please tell us about which provider you’re speaking. This might help other users who are running into the same problem.