Exception: The requested uri cannot be processed by the script

Nextcloud version (eg, 12.0.2): 15.0.7
Operating system and version (eg, Ubuntu 17.04): CentOS 7
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.6 (CentOS)
PHP version (eg, 7.1): 7.2.10

The issue you are facing:
Whenever I try to access a specific folder in my nextcloud instance, I get the following error:

Exception: The requested uri(/nextcloud/remote.php/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php) cannot be processed by the script ‘/nextcloud/remote.php/dav/files/anonion/Programming/Java related/eclipse/old/eclipse-php’)

I also receive this error when trying to sync with the nextcloud client:

Sabre\DAV\Exception: The REQUEST_URI (/nextcloud/remote.php/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php) did not end with the contents of PATH_INFO (/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php). This server might be misconfigured.

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 349:
Sabre\DAV\Server->guessBaseUri()

/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253: 
Sabre\DAV\Server->getBaseUri()

/var/www/html/nextcloud/remote.php - line 72:
Sabre\DAV\Server->exec()

/var/www/html/nextcloud/remote.php - line 166:
handleException(Exception {})

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. I can sometimes reproduce this issue by doing the following:
    1. Create a new folder that has a space in it
    2. Go into the newly created folder
    3. Create a new folder that has at least php- in the name
    • This is extremely inconsistent, but the path that I listed above has always given me an error

The output of your Nextcloud log in Admin > Logging:

Exception: The requested uri(/nextcloud/remote.php/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php) cannot be processed by the script '/nextcloud/remote.php/dav/files/anonion/Programming/Java related/eclipse/old/eclipse-php')

    /var/www/html/nextcloud/lib/private/AppFramework/Http/Request.php - line 810:
    OC\AppFramework\Http\Request->getRawPathInfo()

    /var/www/html/nextcloud/remote.php - line 125:
    OC\AppFramework\Http\Request->getPathInfo()

And the following

Sabre\DAV\Exception: The REQUEST_URI (/nextcloud/remote.php/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php) did not end with the contents of PATH_INFO (/dav/files/anonion/Programming/Java%20related/eclipse/old/eclipse-php). This server might be misconfigured.

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 349:
    Sabre\DAV\Server->guessBaseUri()

    /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:
    Sabre\DAV\Server->getBaseUri()

    /var/www/html/nextcloud/remote.php - line 72:
    Sabre\DAV\Server->exec()

    /var/www/html/nextcloud/remote.php - line 166:
    handleException(Exception {})

The output of your config.php file in /var/www/html/nextcloud/config/config.php (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'oczig1kk2j1v',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => 'domain0',
    1 => 'domain1',
  ),
  'trusted_proxies' => ['internal proxy IP'],
  'datadirectory' => '/mnt/storage/nextcloud',
  'overwrite.cli.url' => 'https://nextcloudURL/nextcloud',
  'htaccess.RewriteBase' => '/nextcloud',
  'overwritewebroot' => '/nextcloud',
  'overwriteprotocol' => 'https',
  'dbtype' => 'mysql',
  'version' => '15.0.7.0',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'dbuser',
  'dbpassword' => 'dbpassword',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

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

[Sun Apr 14 04:39:01.413806 2019] [auth_digest:notice] [pid 9734] AH01757: generating secret for digest authentication ...
[Sun Apr 14 04:39:01.417151 2019] [lbmethod_heartbeat:notice] [pid 9734] AH02282: No slotmem from mod_heartmonitor
[Sun Apr 14 04:39:01.418329 2019] [ssl:warn] [pid 9734] AH01909: RSA certificate configured for nextcloud.home.local:443 does NOT include an ID which matches the server name
[Sun Apr 14 04:39:01.418377 2019] [ssl:warn] [pid 9734] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun Apr 14 04:39:01.447365 2019] [mpm_prefork:notice] [pid 9734] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.10 configured -- resuming normal operations
[Sun Apr 14 04:39:01.447376 2019] [core:notice] [pid 9734] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Apr 15 02:30:17.346819 2019] [mpm_prefork:notice] [pid 9734] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Apr 15 02:30:18.417426 2019] [suexec:notice] [pid 32047] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Apr 15 02:30:18.417870 2019] [ssl:warn] [pid 32047] AH01909: RSA certificate configured for nextcloud.home.local:443 does NOT include an ID which matches the server name
[Mon Apr 15 02:30:18.417909 2019] [ssl:warn] [pid 32047] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Apr 15 02:30:18.429983 2019] [auth_digest:notice] [pid 32047] AH01757: generating secret for digest authentication ...
[Mon Apr 15 02:30:18.430412 2019] [lbmethod_heartbeat:notice] [pid 32047] AH02282: No slotmem from mod_heartmonitor
[Mon Apr 15 02:30:18.430829 2019] [ssl:warn] [pid 32047] AH01909: RSA certificate configured for nextcloud.home.local:443 does NOT include an ID which matches the server name
[Mon Apr 15 02:30:18.430868 2019] [ssl:warn] [pid 32047] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Apr 15 02:30:18.448561 2019] [mpm_prefork:notice] [pid 32047] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.10 configured -- resuming normal operations
[Mon Apr 15 02:30:18.448578 2019] [core:notice] [pid 32047] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Apr 15 02:38:35.865292 2019] [mpm_prefork:notice] [pid 32047] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Apr 15 02:38:36.918622 2019] [suexec:notice] [pid 32218] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Apr 15 02:38:36.919117 2019] [ssl:warn] [pid 32218] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Apr 15 02:38:36.931343 2019] [auth_digest:notice] [pid 32218] AH01757: generating secret for digest authentication ...
[Mon Apr 15 02:38:36.931760 2019] [lbmethod_heartbeat:notice] [pid 32218] AH02282: No slotmem from mod_heartmonitor
[Mon Apr 15 02:38:36.932238 2019] [ssl:warn] [pid 32218] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Apr 15 02:38:36.949975 2019] [mpm_prefork:notice] [pid 32218] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.10 configured -- resuming normal operations
[Mon Apr 15 02:38:36.949995 2019] [core:notice] [pid 32218] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Apr 18 00:03:22.355572 2019] [proxy_fcgi:error] [pid 32551] [client 192.168.0.114:59872] AH01071: Got error 'Primary script unknown\n'
[Thu Apr 18 00:55:18.983860 2019] [php7:error] [pid 5522] [client 192.168.0.114:49602] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 00:55:22.148904 2019] [php7:emerg] [pid 15404] [client 192.168.0.114:49604] PHP Parse error:  syntax error, unexpected '192.168' (T_DNUMBER), expecting ')' in /var/www/html/nextcloud/config/config.php on line 11
[Thu Apr 18 01:03:36.551856 2019] [autoindex:error] [pid 5522] [client 192.168.0.114:50586] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (none) found, and server-generated directory index forbidden by Options directive
[Thu Apr 18 01:10:53.715719 2019] [php7:emerg] [pid 32406] [client 192.168.0.114:52072] PHP Parse error:  syntax error, unexpected ''dbname'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /var/www/html/nextcloud/config/config.php on line 18
[Thu Apr 18 01:10:56.789762 2019] [php7:error] [pid 8580] [client 192.168.0.114:52092] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:10:57.587489 2019] [php7:error] [pid 32551] [client 192.168.0.114:52094] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:10:59.856760 2019] [php7:emerg] [pid 15362] [client 192.168.0.114:52096] PHP Parse error:  syntax error, unexpected ''dbname'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /var/www/html/nextcloud/config/config.php on line 18
[Thu Apr 18 01:11:00.176061 2019] [php7:emerg] [pid 32222] [client 192.168.0.114:52100] PHP Parse error:  syntax error, unexpected ''dbname'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /var/www/html/nextcloud/config/config.php on line 18
[Thu Apr 18 01:11:01.830637 2019] [php7:error] [pid 10090] [client 192.168.0.114:52106] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:11:06.014681 2019] [proxy_fcgi:error] [pid 15970] [client 192.168.0.114:52108] AH01071: Got error 'Primary script unknown\n'
[Thu Apr 18 01:11:06.876493 2019] [php7:error] [pid 32406] [client 192.168.0.114:52116] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:11:11.920061 2019] [php7:error] [pid 15362] [client 192.168.0.114:52130] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:11:16.962316 2019] [php7:error] [pid 10091] [client 192.168.0.114:52134] PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /var/www/html/nextcloud/remote.php:49\nStack trace:\n#0 /var/www/html/nextcloud/remote.php(168): handleException(Object(ParseError))\n#1 {main}\n  thrown in /var/www/html/nextcloud/remote.php on line 49
[Thu Apr 18 01:11:27.387719 2019] [proxy_fcgi:error] [pid 15362] [client 192.168.0.114:52318] AH01068: Got bogus version 173
[Thu Apr 18 01:14:45.787505 2019] [php7:error] [pid 15853] [client 192.168.0.114:52730] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:14:45.788776 2019] [php7:error] [pid 16107] [client 192.168.0.114:52732] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:15:14.414443 2019] [php7:error] [pid 15970] [client 192.168.0.114:52840] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:15:14.414495 2019] [php7:error] [pid 32551] [client 192.168.0.114:52842] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:15:16.907359 2019] [php7:error] [pid 15970] [client 192.168.0.114:53024] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:15:16.908202 2019] [php7:error] [pid 16235] [client 192.168.0.114:53026] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:16:10.451890 2019] [php7:error] [pid 10090] [client 192.168.0.114:53152] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:16:10.451977 2019] [php7:error] [pid 32285] [client 192.168.0.114:53150] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:19:01.069471 2019] [php7:error] [pid 15853] [client 192.168.0.114:53532] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:19:01.070133 2019] [php7:error] [pid 10090] [client 192.168.0.114:53534] script '/var/www/html/remote.php' not found or unable to stat
[Thu Apr 18 01:19:12.175365 2019] [proxy_fcgi:error] [pid 10091] [client 192.168.0.114:53576] AH01068: Got bogus version 173
[Thu Apr 18 01:20:25.811450 2019] [proxy_fcgi:error] [pid 32551] [client 192.168.0.114:53782] AH01068: Got bogus version 173
[Thu Apr 18 01:21:32.497207 2019] [proxy_fcgi:error] [pid 8580] [client 192.168.0.26:50680] AH01071: Got error 'Primary script unknown\n'
[Thu Apr 18 01:36:22.808401 2019] [proxy_fcgi:error] [pid 16991] [client 192.168.0.26:51909] AH01068: Got bogus version 204
[Thu Apr 18 01:36:40.224939 2019] [proxy_fcgi:error] [pid 16743] [client 192.168.0.114:55700] AH01071: Got error 'Primary script unknown\n'
[Thu Apr 18 01:36:46.539724 2019] [autoindex:error] [pid 16991] [client 192.168.0.114:55708] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (none) found, and server-generated directory index forbidden by Options directive

The errors in the httpd error log don’t happen every time nextcloud encounters the exception. Not sure what triggers errors to be generated in the error_log file.

And to add to the mystery, it works fine when I browse to the folder on the Nextcloud android app.

Had to reinstall nextcloud-server. Not sure why, but the client and web gui don’t have any complains now.