PHP 'Failed to Open Stream: No Such File or Directory' on include or require
The path in your include is wrong after moving files. Use absolute paths based on __DIR__.
Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
This error means PHP cannot find the file you included.
Fixes
- Check the exact name and letter case. Linux is case sensitive. See our HTML paths guide.
- Use paths based on the current file instead of the working directory:
require_once __DIR__ . '/includes/config.php';
- Relative paths like
../config.phpdepend on the script that is running, not the included file. - Make sure the file was uploaded and permissions allow reading.
- After moving a site, absolute server paths in config files may still point to the old server.
Related
See our PHP errors guide.
Related guides
- YouTube Video Embed Not Working or Showing an Error on Your Website
- WordPress XML Sitemap Gives 404 or Is Not Generating
- Changed the WordPress Address (URL) and Now the Site or Login Is Broken
- wp-config.php Explained: The Settings That Matter and How to Edit Them Safely
Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.