Skip to content
PHP and Laravel2 min read

"open_basedir restriction in effect": what it means and how to fix it

open_basedir restriction in effect. File(/var/www/html/uploads) is not within the allowed path(s)

Short answer

The error means code tried to read or write a file outside the folders allowed by the open_basedir setting. Most often it's an old absolute path, from a previous server or your own computer, stored in a config or cache file. Fix the path so it points inside your account, or build paths with __DIR__.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What the error means
  2. Common causes
  3. How to fix it
  4. Prevention
  5. On ArabyHost

open_basedir is a PHP security setting that confines file operations to specific folders, so a script on your site can’t read system files or other accounts’ files. The warning is genuinely helpful: it tells you both the rejected path and the allowed ones.

What the error means

Warning: file_exists(): open_basedir restriction in effect. File(/var/www/html/uploads/logo.png) is not within the allowed path(s): (/home/user:/tmp) in /home/user/public_html/inc/media.php on line 31
  • file_exists(): the function that tried to access the file.
  • File(/var/www/html/uploads/logo.png): the rejected path.
  • allowed path(s): (/home/user:/tmp): the allowed folders, separated by colons.

The rejected /var/www/html doesn’t even exist in your account; it’s a common path on other servers. That’s the classic pattern behind this error.

Common causes

  • An old absolute path after a migration, such as /home/olduser/public_html or /var/www/html, saved in settings.
  • Laravel’s config cache: bootstrap/cache/config.php stores full paths from when it was built, sometimes from your machine, like C:\laragon\www\myapp.
  • WordPress plugin settings that store absolute paths (cache, backup and security plugins), or an old auto_prepend_file line in .user.ini.
  • A temp folder outside the allowed list, which can also trigger WordPress’s missing temporary folder error.
  • Symlinks pointing outside your account.
  • Code reading system files under /etc or /usr/share.

How to fix it

  1. Read both paths in the message: rejected and allowed. The full text is in cPanel under Metrics › Errors or in the error_log file.
  2. Search for the old path in the usual config files via Files › File Manager: wp-config.php, .user.ini, .htaccess, Joomla’s configuration.php and Laravel’s .env. With SSH:
grep -rn "/home/olduser" ~/public_html --include=*.php --include=.user.ini --include=.htaccess
  1. In Laravel, clear the config cache so it’s rebuilt with the new paths:
php artisan config:clear
php artisan config:cache

Without SSH, delete bootstrap/cache/config.php by hand. 4. In WordPress, open and re-save the settings of cache and backup plugins, or reinstall the plugin named in the message. Remove any auto_prepend_file line with an old path from .user.ini. 5. Write paths that don’t depend on the server:

// instead of '/var/www/html/uploads'
$uploadDir = __DIR__ . '/uploads';

// a temp folder inside your account
$tmpDir = dirname(__DIR__) . '/tmp';
  1. Don’t try to widen the restriction in code: ini_set('open_basedir', ...) only accepts a narrower value. If you think a legitimate path should be allowed, ask support.

Prevention

  • Avoid hard-coded absolute paths; use __DIR__ and framework helpers such as Laravel’s storage_path().
  • Don’t upload cache files generated on your computer to the server.
  • After every migration, search config files for the old username and path; see the cPanel-to-cPanel migration guide.

On ArabyHost

Every account is isolated in CloudLinux CageFS, and your site’s files live under your home folder /home/USER, so keep every path inside it. The Araby AI assistant reads the error log and points to the file and old path behind the warning. If you’re moving a site from another host, see our free migration help.

FAQ

Can I turn off open_basedir from my code?

No. ini_set can tighten open_basedir at runtime but can't widen it to paths the server doesn't allow. The right fix is making your code use paths inside the allowed folders.

How do I see which folders are allowed?

The message lists them in brackets after "allowed path(s)", separated by colons. You can also see the open_basedir value on a phpinfo() page.

Why did this appear after moving a Laravel site?

bootstrap/cache/config.php stores absolute paths from the old server or your own machine. Delete it or run php artisan config:clear so it's rebuilt with the new paths.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.