open_basedir 🐘 PHP

Warning: file_exists(): open_basedir restriction in effect. File(/x) is not within the allowed path(s)

PHP is configured to access only certain directories, and the script tried to touch a file outside them.

Seen on: PHP

Meaning

Shared hosts set open_basedir to your account directory. Paths outside it — /tmp, another site’s folder, or absolute paths copied from a different server — are blocked.

Common causes

  • Absolute path from another server/environment
  • Temp/upload directory outside the allowed paths
  • Symlinks pointing outside the allowed tree

⚡ Quick fix

  1. Use paths inside your account (e.g. __DIR__-relative)
  2. Set upload_tmp_dir/sys_get_temp_dir() to a directory inside the allowed paths
  3. Ask the host or adjust open_basedir in the PHP selector

Detailed fix by platform

PHP

  1. Check the current value with ini_get('open_basedir')

How to diagnose

  1. Allowed — Which paths are allowed (in the message)?
  2. Requested — Which path did you use?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.