Troubleshooting · Troubleshooting
How to Fix "Failed to Open Stream" in WordPress
Short answer
A “failed to open stream” warning means PHP tried to open a file or web address and could not. Read the full message to find the path and the reason, such as a missing file, denied permission or a blocked setting. Then restore the file, fix the path or permission, or ask your host to change the PHP setting.
Key takeaways
- The warning names the file path and the reason, such as no such file or permission denied, so read the full line first.
- fopen() returns false and emits a warning when it cannot open a file, and file_get_contents() also returns false on failure.
- A wrong path is the most common cause, often after a move, a failed update or a renamed folder.
- Directories usually use permission 755 and files use 644, but your host may need a different setup.
- WP_DEBUG_LOG set to true writes errors to wp-content/debug.log, which helps you find the exact file and line.
- If the path is outside open_basedir or the address needs allow_url_fopen, only your host can change that setting on many plans.
What does “failed to open stream” mean in WordPress?
It means PHP tried to open a file or a web address and could not, so the step that needed that file did not finish.
The message is a PHP warning, not a full page error by itself. WordPress is built on PHP, so a plugin, a theme or WordPress core can trigger it when it reads a file.
The PHP Manual for fopen() states that the function returns false on failure and emits a warning. That warning is the text you see on screen or in a log.
The same idea applies to other file functions. The PHP Manual for file_get_contents() states that it returns false on failure and emits a warning if the file cannot be found, as of November 2026.
What causes the error most often?
A missing file, a wrong path, denied permission or a blocked PHP setting causes most cases.
Start with the path in the message. A file may have been deleted, moved, renamed or left out by a failed update.
A relative path can also point to the wrong folder. PHP reads a relative path from the current working folder, which may differ from the folder you expect.
Permissions are the next cause. If the PHP process cannot read the file or enter its folder, the open fails even when the file exists.
Server settings can block the open too. The open_basedir setting limits PHP to a set folder tree, and allow_url_fopen controls whether PHP can open web addresses as files.
A broken plugin or theme is a common trigger in WordPress. If it asks for a file that its update did not install, the warning appears on every page that loads that code. A related server error may need a different fix, as in our guide to fix a 500 internal server error.
How do you read the full error message?
Copy the full warning line, because it names the file path, the reason and the line of code that failed.
A typical line looks like this: Warning: fopen(/home/example/public_html/wp-content/plugins/example/file.php): failed to open stream: No such file or directory in /home/example/public_html/wp-content/plugins/example/main.php on line 42.
Read it in three parts. The first part names the file PHP tried to open, and the middle part gives the reason.
The last part names the file and line that made the request.
| Message part | What it tells you | First action |
|---|---|---|
| No such file or directory | The path is wrong or the file is gone | Check the path and restore the file |
| Permission denied | PHP cannot read the file or folder | Check permissions and ownership |
| Operation not permitted | A server rule blocks the open | Check open_basedir with your host |
| No suitable wrapper could be found | The address type is not allowed | Check allow_url_fopen and the address |
| HTTP request failed | The remote address did not answer | Check the address and the remote site |
If the message only shows on one page, note which page it is. If it shows on every page, the fault is likely in a plugin, a theme or a file loaded on every request.
How do you turn on the WordPress debug log?
Set WP_DEBUG and WP_DEBUG_LOG to true in wp-config.php, and the errors will be written to wp-content/debug.log.
First, back up your site. Then open wp-config.php in your hosting file manager or by SFTP. It sits in the root folder of your WordPress install.
Find the line define( 'WP_DEBUG', false ); and change false to true. Add the two lines below it, above the line that says “That's all, stop editing!”:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
The WordPress debugging guide states that WP_DEBUG defaults to false, and that WP_DEBUG_LOG set to true logs errors to the debug.log file in the /wp-content directory (Debugging in WordPress).
Kinsta's debugging guide gives the same result: when WP_DEBUG_LOG is true, WordPress writes issues to wp-content/debug.log, and you can set a custom path instead (WordPress debugging guide).
Reload the page that shows the error, then open wp-content/debug.log. Search for “failed to open stream” and copy the newest lines. Turn debug mode off when you finish, so the log does not grow and visitors do not see errors.
How do you fix a missing or moved file?
Restore the missing file from a backup, or reinstall the plugin or theme that owns it.
First, check whether the path in the message exists. Use your hosting file manager or SFTP to open each folder in the path, one level at a time.
If a folder name is wrong by one letter, fix the code or the folder name to match. Do not guess a new path. Use the exact path from the error message.
If the file belongs to a plugin, reinstall that plugin. Go to “Dashboard → Plugins”, deactivate the plugin, delete it, then install it again from WordPress.org or from the copy you bought.
If the file belongs to a theme, reinstall the theme the same way from “Dashboard → Appearance → Themes”. Keep a copy of any custom changes first, because reinstalling replaces theme files.
If the file is a media file or an upload, restore it from a backup. If you have no backup, upload the file again to the exact folder in the message. A failed update can leave a site in this state, as in our guide to fix briefly unavailable for scheduled maintenance.
How do you fix file permission problems?
Set folders to 755 and files to 644, then check that the file owner matches the account your host expects.
Permissions decide who can read, write and run a file. WordPress may need write access to files in wp-content to run some tasks, according to the WordPress guide to changing file permissions.
Use your hosting file manager or SFTP to check the file in the error message. Right-click the file, open “Permissions” or “Change permissions”, and set it to 644. Do the same for its folder, and set the folder to 755.
If many files are wrong, fix them in bulk with care. In a terminal, the WordPress guide's scheme is 755 for folders and 644 for files, but only use terminal commands if your host supports them and you have a backup.
Do not set files or folders to 777. That value lets anyone write to them, and it is a security risk. If 644 and 755 do not fix the error, the owner may be wrong, so ask your host to check ownership.
Check the result in “Dashboard → Tools → Site Health → Info”, then open “Filesystem Permissions”. WordPress lists the folders it can write to there, as of November 2026.
How do you fix an open_basedir or allow_url_fopen problem?
Move the file inside the allowed folder, or ask your host to widen open_basedir or turn on allow_url_fopen.
The open_basedir setting limits the files PHP can open to a set folder tree. When a script tries to open a file outside that tree, PHP refuses it, and symbolic links do not bypass the limit.
The PHP Manual for fopen() also states that for a network address, PHP checks allow_url_fopen, and if it is off, PHP emits a warning and the call fails.
Check the two settings first. In “Dashboard → Tools → Site Health → Info”, open “Server” and look for the PHP settings, or ask your host to print the values for open_basedir and allow_url_fopen.
Fix an open_basedir error
- Move the file into the folder tree named in
open_basedir, if you control that folder. - Change the path in the plugin or theme settings to the new location.
- Ask your host to add the folder to
open_basedirif the file must stay where it is.
Fix an allow_url_fopen error
- Check that the address starts with
https://and has no typing error. - Ask your host to turn on
allow_url_fopenif the plugin must read a remote address. - If the host will not turn it on, use a plugin that fetches remote data with a different method, such as the WordPress HTTP API.
The OWASP PHP configuration guide recommends allow_url_fopen = Off and allow_url_include = Off in its sample settings (OWASP PHP Configuration Cheat Sheet). Only turn the setting on when a feature you need requires it.
How do you fix a broken plugin or theme that triggers it?
Deactivate the plugin or switch the theme, then update or replace the item that caused the warning.
If you can open the dashboard, go to “Dashboard → Plugins”, find the plugin named in the error path, and click “Deactivate”. Reload the site. If the warning is gone, that plugin is the source.
If you cannot open the dashboard, rename the plugin folder by SFTP or in the file manager. Open wp-content/plugins/, rename the folder to add -off at the end, and reload the site. WordPress will treat the plugin as missing and skip it.
Do the same test for a theme. Go to “Dashboard → Appearance → Themes” and switch to a default theme such as Twenty Twenty-Five. If the warning stops, the old theme is the source.
Then update the faulty item, or replace it. An old plugin may ask for a file that a newer WordPress version moved, so check its WordPress.org page for a recent update and for the tested version.
WordPress 5.2 added a fatal error handler so a bad theme or plugin does not lock you out of the site, according to the WordPress debugging guide. That handler helps with fatal errors, but a warning like this one still needs the file fix above.
How do you know the fix worked?
Reload the affected page with debug logging on, and check that the warning is gone from the screen and from debug.log.
Reload the page twice. The first load may use a cached copy, so the second load gives a truer result. Clear your cache plugin if you use one.
Open wp-content/debug.log and search for the file path from the first error. No new line for that path means the open now works. Check the page itself too: images, forms and menus should load as normal.
Test the feature that failed. If the error came from an upload, upload a small test file. If it came from a plugin page, open that plugin's settings page and save a setting.
Watch the log for a day. A fix that works on one page can fail on another page that opens a different file. If a new warning names a different file, repeat the same steps for that path.
If the error was tied to a memory limit rather than a missing file, read our guide to fix allowed memory size exhausted.
If you need to change the PHP version as part of the fix, see how to update the PHP version in WordPress.
When should you contact your host?
Contact your host when the fix needs a server setting, file ownership or a folder you cannot reach.
Ask your host for help in these cases:
- The path is outside
open_basedirand you cannot move the file. allow_url_fopenis off and a plugin you need requires it.- Permissions look right at 755 and 644, but the error still says permission denied.
- You cannot reach the file by SFTP or the file manager.
- The error started right after a server move or a PHP version change.
Give the host the full warning line, the page where it appears, and the steps you already tried. That list lets support check the exact path and setting without guessing.
Ask for the current values of open_basedir, allow_url_fopen and the PHP version. If the host changed a setting, ask them to confirm the change and the time it was made, as of November 2026.
What mistakes should you avoid?
Do not hide the warning, set permissions to 777, or edit core WordPress files to work around it.
Hiding the warning leaves the broken feature in place. Turn on logging, fix the cause, then turn debug mode off.
Do not set folders or files to 777 to make an error go away. That setting lets any user on the server write to them. Use 755 for folders and 644 for files, and ask your host about ownership if that fails.
Do not edit WordPress core files. Core updates replace those files, so your edit will vanish and the error will return. Fix the plugin, theme or setting that asks for the file.
Do not turn on allow_url_fopen for every site on a shared plan. Only enable it where a feature needs it, and keep allow_url_include off. Check the WordPress hosting requirements before you ask your host to change a PHP setting.
Frequently asked questions
Is failed to open stream a fatal error?
No, it is a PHP warning in most cases. PHP returns false from the file function and keeps running, but the step that needed the file fails. The page may still load with a missing image, a broken feature or a blank section. Treat it as a real fault even when the page loads, because the missing file can break updates, uploads or a plugin feature.
Can I fix it by turning off WP_DEBUG?
No, turning off WP_DEBUG only hides the message. The file is still missing or still blocked, so the feature that needed it still fails. Use WP_DEBUG_LOG to record the full message, fix the path, permission or setting, then turn debug mode off. Hiding the warning without a fix leaves the fault in place for visitors and for later updates.
Why does the error appear after a migration?
A migration often changes the server path, such as the home folder or the domain folder. Code that stored the old absolute path then asks for a file at a location that no longer exists. Check the path in the warning against the new server layout, update the stored path in the plugin or theme settings, and restore any file that did not copy over during the move.
What if the file exists but PHP still cannot open it?
Check permissions and ownership first, then check open_basedir. A file can exist and still be unreadable if its permission is too strict or its owner differs from the account PHP runs as. If the path sits outside the folder tree named in open_basedir, PHP will refuse it even with open permissions. Your host can confirm both values for you.
Should I enable allow_url_fopen to fix a remote file error?
Only if a feature you need must read a remote address with a file function, and your host agrees. Many hosts keep it off for safety, and some plugins can use the WordPress HTTP API instead. Ask the plugin author whether it needs that setting, and keep allow_url_include off. If the remote address itself is wrong or down, turning the setting on will not help.
How do I stop debug.log from growing too large?
Turn off WP_DEBUG when you finish fixing the error, and delete or empty the debug.log file in wp-content. The log records every warning while debug mode is on, so a busy site can fill it fast. Check the file size before you delete it, and keep a copy of the lines you still need for your host or for the plugin author.
Sources
- fopen - PHP Manual PHP.net
- file_get_contents - PHP Manual PHP.net
- Debugging in WordPress Developer.WordPress.org
- Changing File Permissions WordPress.org
- PHP Configuration Cheat Sheet OWASP
- A Complete Guide to WordPress Debugging Kinsta
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
