Nextcloud on shared host, occ not working

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 35.0.2.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Linux
  • Web server and version (e.g, Apache 2.4.25):
    • Apache
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx
  • PHP version (e.g, 8.3):
    • 8.4.27
  • Is this the first time you’ve seen this error? (Yes / No):
    • No
  • When did this problem seem to first start?
    • from start
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare / shared hosting
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

In bash occ command does not work as it appears to be unable to connect to the database

\> /opt/plesk/php/8.3/bin/php ./occ 
An unhandled exception has been thrown: 
Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE\[HY000\] \[2002\] No such file or directory in /kingma.cloud/lib/private/DB/C
onnection.php:236 
Stack trace: 
#0 /kingma.cloud/3rdparty/doctrine/dbal/src/Connection.php(458): OC\\DB\\Connection->connect() 
#1 /kingma.cloud/3rdparty/doctrine/dbal/src/Connection.php(416): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion() 
#2 /kingma.cloud/3rdparty/doctrine/dbal/src/Connection.php(323): Doctrine\\DBAL\\Connection->detectDatabasePlatform() 
#3 /kingma.cloud/lib/private/DB/Connection.php(946): Doctrine\\DBAL\\Connection->getDatabasePlatform() 
#4 /kingma.cloud/lib/private/DB/ConnectionAdapter.php(278): OC\\DB\\Connection->getDatabaseProvider(false) 
#5 /kingma.cloud/lib/private/DB/QueryBuilder/QueryBuilder.php(86): OC\\DB\\ConnectionAdapter->getDatabaseProvider() 
#6 /kingma.cloud/lib/private/AppConfig.php(1428): OC\\DB\\QueryBuilder\\QueryBuilder->expr() 
#7 /kingma.cloud/lib/private/AppConfig.php(310): OC\\AppConfig->loadConfig(NULL, false) 
#8 /kingma.cloud/lib/private/AppConfig.php(1925): OC\\AppConfig->searchValues('installed_versi...', false, 4) 
#9 /kingma.cloud/lib/private/Memcache/Factory.php(125): OC\\AppConfig->getAppInstalledVersions(true) 
#10 /kingma.cloud/lib/private/Memcache/Factory.php(167): OC\\Memcache\\Factory->getGlobalPrefix() 
#11 /kingma.cloud/lib/private/Server.php(875): OC\\Memcache\\Factory->createLocking('lock') 
#12 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(178): OC\\Server->OC\\{closure}(Object(OC\\Server)) 
#13 /kingma.cloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\\AppFramework\\Utility\\SimpleContainer->OC\\AppFramework\\Utility\\{closure}(Object(Pimple\\Container)) 
#14 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(152): Pimple\\Container->offsetGet('OCP\\\\Lock\\\\ILocki...') 
#15 /kingma.cloud/lib/private/ServerContainer.php(150): OC\\AppFramework\\Utility\\SimpleContainer->query('OCP\\\\Lock\\\\ILocki...', true, Array) 
#16 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(46): OC\\ServerContainer->query('OCP\\\\Lock\\\\ILocki...') 
#17 /kingma.cloud/lib/public/Server.php(38): OC\\AppFramework\\Utility\\SimpleContainer->get('OCP\\\\Lock\\\\ILocki...') 
#18 /kingma.cloud/lib/private/Files/View.php(91): OCP\\Server::get('OCP\\\\Lock\\\\ILocki...') 
#19 /kingma.cloud/lib/private/Server.php(350): OC\\Files\\View->\__construct() 
#20 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(178): OC\\Server->OC\\{closure}(Object(OC\\Server)) 
#21 /kingma.cloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\\AppFramework\\Utility\\SimpleContainer->OC\\AppFramework\\Utility\\{closure}(Object(Pimple\\Container)) 
#22 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(152): Pimple\\Container->offsetGet('OC\\\\Files\\\\View') 
#23 /kingma.cloud/lib/private/ServerContainer.php(150): OC\\AppFramework\\Utility\\SimpleContainer->query('OC\\\\Files\\\\View', true, Array) 
#24 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(96): OC\\ServerContainer->query('OC\\\\Files\\\\View', true, Array) 
#25 \[internal function\]: OC\\AppFramework\\Utility\\SimpleContainer->OC\\AppFramework\\Utility\\{closure}(Object(ReflectionParameter)) 
#26 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(83): array_map(Object(Closure), Array) 
#27 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(75): OC\\AppFramework\\Utility\\SimpleContainer->buildClassConstructorParameters(Object(ReflectionMethod), Arra
y) 
#28 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(133): OC\\AppFramework\\Utility\\SimpleContainer->buildClass(Object(ReflectionClass), Array) 
#29 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\\AppFramework\\Utility\\SimpleContainer->resolve('OC\\\\Files\\\\Node\\\\H...', Array) 
#30 /kingma.cloud/lib/private/ServerContainer.php(150): OC\\AppFramework\\Utility\\SimpleContainer->query('OC\\\\Files\\\\Node\\\\H...', true, Array) 
#31 /kingma.cloud/lib/private/AppFramework/Utility/SimpleContainer.php(46): OC\\ServerContainer->query('OC\\\\Files\\\\Node\\\\H...') 
#32 /kingma.cloud/lib/private/Server.php(1188): OC\\AppFramework\\Utility\\SimpleContainer->get('OC\\\\Files\\\\Node\\\\H...') 
#33 /kingma.cloud/lib/OC.php(780): OC\\Server->boot() 
#34 /kingma.cloud/lib/base.php(12): OC::initForRequest() 
#35 /kingma.cloud/console.php(32): require_once('/kingma.cloud/l...') 
#36 /kingma.cloud/occ(15): require_once('/kingma.cloud/c...')

Steps to replicate it (hint: details matter!):

  1. Login with ssh
  2. Navigate to nextcloud root
  3. run /opt/plesk/php/8.3/bin/php ./occ

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

None relevant

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

it is occ, not browser

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

[Sun Oct 25 09:38:17.816982 2026] [core:crit] [pid 113142:tid 140343936763648] (13)Permission denied: [client 80.74.152.70:24320] AH00529: /home/httpd/vhosts/king.ma/kingma.cloud/data/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/httpd/vhosts/king.ma/kingma.cloud/data/' is executable
[Sun Oct 25 09:38:17.826371 2026] [core:crit] [pid 113142:tid 140343575877376] (13)Permission denied: [client 80.74.152.70:24334] AH00529: /home/httpd/vhosts/king.ma/kingma.cloud/data/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/httpd/vhosts/king.ma/kingma.cloud/data/' is executable

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

occ is not working

Apps

The output of occ app:list (if possible).

occ is not working

Tips for increasing the likelihood of a response

  • Use the preformatted text formatting option in the editor for all log entries and configuration output.
  • If screenshots are useful, feel free to include them.
    • If possible, also include key error output in text form so it can be searched for.
  • Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.

Does your configuration (config/config.php) include the following?

'dbhost' => 'localhost',

If so, try:

'dbhost' => '127.0.0.1',

Background: If you use localhost the MySQL extension attempts to connect to localhost not only via TCP but also via a unix socket. I think that’s possible in your case because:

This is only a problem if your hosting provider loads a different php.ini file for CLI than for PHP-FPM. And one of them is configured incorrectly. Or the SSH user has different permissions than PHP-FPM, so does not have permission for the socket