Operation is blocked by access control ubuntu 24.04 Apache

Nextcloud version: 29.0.0
Operating system and version: Ubuntu 24.04 LTS
Apache or nginx version: Apache/2.4.58 (Ubuntu)
PHP version: 8.3.7
MySQL version: 8.0.36-2ubuntu3

The issue you are facing: Can’t upload files after a fresh installation of all software in the server after formatting.

Is this the first time you’ve seen this error? Yes

There is no output of your Nextcloud log in Admin > Logging:

config.php:

<?php
$CONFIG = array (
  'instanceid' => 'ocgxzbhkuuvo',
  'passwordsalt' => 'Yo1B1DNaGNkqBem6zno1qbe6YUUHqd',
  'secret' => 'FSG8AWFQnwGaC1vvh4zIx2+29YhimLVfNkc/9/EVMkkmfb3j',
  'datadirectory' => '/var/www/html/test/nextcloud29/data',
  'dbtype' => 'mysql',
  'version' => '29.0.0.19',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'installed' => true,
);

Apache log:

[Tue May 21 17:28:27.280015 2024] [php:error] [pid 89942] [client 10.71.128.100:51770] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat
[Tue May 21 17:28:27.302749 2024] [php:error] [pid 89942] [client 10.71.128.100:51770] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat
[Tue May 21 17:34:17.752953 2024] [access_compat:error] [pid 89037] [client 10.71.128.100:40256] AH01797: client denied by server configuration: /var/www/html/test/nextcloud29/data/.ocdata
[Tue May 21 17:34:17.886650 2024] [access_compat:error] [pid 89037] [client 10.71.128.100:40256] AH01797: client denied by server configuration: /var/www/html/test/nextcloud29/data/.ocdata
[Tue May 21 17:34:20.969200 2024] [php:error] [pid 89073] [client 10.71.128.100:34096] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat
[Tue May 21 17:34:20.993312 2024] [php:error] [pid 89073] [client 10.71.128.100:34096] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat
[Tue May 21 17:37:19.968276 2024] [access_compat:error] [pid 90313] [client 10.71.128.100:45772] AH01797: client denied by server configuration: /var/www/html/test/nextcloud29/data/.ocdata
[Tue May 21 17:37:20.097607 2024] [access_compat:error] [pid 90313] [client 10.71.128.100:45772] AH01797: client denied by server configuration: /var/www/html/test/nextcloud29/data/.ocdata
[Tue May 21 17:37:23.131605 2024] [php:error] [pid 89941] [client 10.71.128.100:45830] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat
[Tue May 21 17:37:23.161715 2024] [php:error] [pid 89941] [client 10.71.128.100:45830] script '/var/www/html/pathospotterhome/index.php' not found or unable to stat

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"FsMJykXsWk5tdrhVwaQS","level":3,"time":"2024-05-21T16:53:18+00:00","remoteAddr":"179.54.107.52","user":"--","app":"mysql.setup","method":"POST","url":"/test/nextcloud29/","message":"Database creation failed.","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15","version":"29.0.0.19","exception":{"Exception":"Doctrine\\DBAL\\Exception\\ConnectionException","Message":"An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'ncroot'@'localhost' to database 'nextcloud'","Code":1044,"Trace":[{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1943,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->","args":[["Doctrine\\DBAL\\Driver\\PDO\\Exception"],["Doctrine\\DBAL\\Query"]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1885,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->","args":[["Doctrine\\DBAL\\Driver\\PDO\\Exception"],["Doctrine\\DBAL\\Query"]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1213,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":[["Doctrine\\DBAL\\Driver\\PDO\\Exception"],"CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php","line":292,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":360,"function":"executeStatement","class":"Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1969,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":334,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":91,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":62,"function":"createDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup.php","line":339,"function":"setupDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["admin"]},{"file":"/var/www/html/test/nextcloud29/core/Controller/SetupController.php","line":68,"function":"install","class":"OC\\Setup","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/base.php","line":998,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/index.php","line":49,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":101,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'ncroot'@'localhost' to database 'nextcloud'","Code":1044,"Trace":[{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":39,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::","args":[["PDOException",["42000",1044,"Access denied for user 'ncroot'@'localhost' to database 'nextcloud'"]]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1211,"function":"exec","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php","line":292,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":360,"function":"executeStatement","class":"Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1969,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":334,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":91,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":62,"function":"createDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup.php","line":339,"function":"setupDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["admin"]},{"file":"/var/www/html/test/nextcloud29/core/Controller/SetupController.php","line":68,"function":"install","class":"OC\\Setup","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/base.php","line":998,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/index.php","line":49,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":28,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'ncroot'@'localhost' to database 'nextcloud'","Code":"42000","Trace":[{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":33,"function":"exec","class":"PDO","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1211,"function":"exec","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php","line":292,"function":"executeStatement","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":360,"function":"executeStatement","class":"Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Connection.php","line":1969,"function":"executeStatement","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/DB/Connection.php","line":334,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;",[],[]]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":91,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["CREATE DATABASE IF NOT EXISTS `nextcloud` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup/MySQL.php","line":62,"function":"createDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/private/Setup.php","line":339,"function":"setupDatabase","class":"OC\\Setup\\MySQL","type":"->","args":["admin"]},{"file":"/var/www/html/test/nextcloud29/core/Controller/SetupController.php","line":68,"function":"install","class":"OC\\Setup","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/lib/base.php","line":998,"function":"run","class":"OC\\Core\\Controller\\SetupController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/test/nextcloud29/index.php","line":49,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/test/nextcloud29/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":33}},"message":"Database creation failed.","exception":{},"CustomMessage":"Database creation failed."}}