Error: file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (/var/customers/webs/pride/nxtcloud:/tmp)

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


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:

Nextcloud version (eg, 20.0.5): 21.0.4
Operating system and version (eg, Ubuntu 20.04): Linux 4.19.0-17-amd64 x86_64
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.4): 7.4.22

The issue you are facing:

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

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

{"reqId":"YSKN011xJ2YFJX18p9JGYQAAAAg","level":3,"time":"2021-08-22T17:48:03+00:00","remoteAddr":"+++++","user":"++++","app":"PHP","method":"GET","url":"/settings/admin/logging","message":{"Exception":"Error","Message":"file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (/var/customers/webs/****/nxtcloud:/tmp) at /var/customers/webs/****/nxtcloud/lib/private/Template/Base.php#68","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/Template/Base.php","line":68,"function":"file_exists"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/legacy/OC_Template.php","line":147,"function":"getAppTemplateDirs","class":"OC\\Template\\Base","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/legacy/OC_Template.php","line":89,"function":"findTemplate","class":"OC_Template","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/TemplateLayout.php","line":92,"function":"__construct","class":"OC_Template","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/legacy/OC_Template.php","line":183,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/public/AppFramework/Http/TemplateResponse.php","line":210,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/AppFramework/Http/Dispatcher.php","line":172,"function":"render","class":"OCP\\AppFramework\\Http\\TemplateResponse","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/customers/webs/****/nxtcloud/lib/base.php","line":993,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/customers/webs/****/nxtcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/customers/webs/****/nxtcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36","version":"","id":"61228dd51497e"}

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

$CONFIG = array (
  'instanceid' => '1234',
  'passwordsalt' => '1234+1234',
  'secret' => '1234/1234+1234',
  'trusted_domains' => 
  array (
    0 => '',
  'datadirectory' => '/var/customers/webs/1234/nxtcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '',
  'dbname' => '1234',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '1234',
  'dbpassword' => '1234',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'cloudservice',
  'mail_domain' => '',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
  'maintenance' => false,
  'default_phone_region' => 'DE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'theme' => '',
  'log_type' => 'file',
  'logfile' => '/var/customers/webs/1234/nxtcloud/data/nextcloud2.log',
  'loglevel' => 2,
  'htaccess.RewriteBase' => '/',
  'mail_sendmailmode' => 'smtp',
  'mysql.utf8mb4' => true,

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


Sorry when I filled the form not really according to the rules.
Anyway - I solved the problem, was a simple upen base misconfiguration, combined with a misses mysql_upgrade and som not really fitting rules in mod-security…

problem solved

I’m getting the same error messages for a while now. How did you fix it? Did you just add /templates/ to your open_basedir?

1 Like

Same at my instance (21.0.4) since a very long time:

Clicking the last left-sidebar-menuitem “system” (logged in as administrator) I’m always getting a blue screen:

Interner Serverfehler

(internal server error)
… and endless logfile-enrtries like this:

Error PHP Error:
file_exists(): open_basedir restriction in effect. File(/templates/) is not within the allowed path(s): (/var/www/vhosts/ at /var/www/vhosts/

I hoped it’d dissapear with an update over time, but “coming back” a few days ago I’d to recognize this problem is still remaining ;-((

Strange thing is that it was a “standard” installation – where I’ve never ever changed any single directories – an this instance is updating obviously automatically without__any problems.

And the result of:

… is: Rating: A+

So I’m feeling a little confused and “left alone”.

In my case it was “mod_sec” core rule set causing the problem. If you’ve these modules activated, I would temporarily disable it – see if it works.

I’m having the same problem.

That error continues to be output continuously in seconds.
Currently I am on NC22.1.1.

Same problem at my NC22.1.0 instance.
Our NC is hosted with a professional managed server, I got the information from technical support that template directory should not be in php system directory, and that might be a NC bug?

I have updated to NC22.2.0 and it has been 6 hours, but this error does not seem to be resolved. This error continues to occur every few minutes on a steady basis.

1 Like

I have updated today to 22.2.0 and log spamming about openbasedir restrictions in Base.php #68 has started. But everything is running as expected. All files and folders that are mentioned in the logs can be accessed (languages, templates, js etc.), upload and download of files is working fine. I have not touched server configurations and ownership of files/folders is correct. I am using Arch Linux. The error messages go away if I disable open_basedir (what I do not want to do permanently).

Not the best solution - but I put an ‘@’ in front of ‘file_exists’ in lib/private/Template/Base.php at line 68 and log spamming goes away. Everything is working fine.
I wonder why it is complaining of not finding some files but there are no issues to see…