“Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0” Error in Joomla

We’re currently having an increasing number of clients emailing us that they’re seeing the following error (repeated twice) on their homepage:

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

The homepage doesn’t display anything else, just this message (again, the message is usually displayed twice).

So, what is the cause of this problem?

As the error message implies, the main cause of this problem is wrong permissions – usually affecting the index.php file (which is usually the first file loaded by the web server, unless there is an index.html file). The permissions on this file are wrongfully set to 000 (which means that no one can read, write, or execute that file). Normally, the index.php‘s permissions should be set to 444.

Now, the 000 permissions make the issue a bit more confusing, since some file managers and FTP managers do not list files with what we call zero permission (which will inaccurately imply that the file has been deleted – while it’s not).

So how can this problem be fixed?

In order to solve the problem, you will need to first go to your file manager. If you have a cPanel powered hosting, then all you need to do is to login to your cPanel and then click on File Manager. Once you’re in the file manager, there are two ways to solve the problem, depending on whether you see the index.php file or not.

  1. If you see the index.php file

    All you need to do is to right click on the index.php and set its permissions to 444. This should fix the problem in most cases.

  2. If you don’t see the index.php file

    If you don’t see the file, then you will need to create another file (call it chmod.php and place it under the root directory of your website) which will contain the following code:

    <?php
    chmod("index.php", 0444);
    ?>

    Once the chmod.php file is created, you will need to run it by pointing your browser to http://www.yourjoomlawebsite.com/chmod.php. The problem is usually fixed when you load that page.

What if the problem is still not fixed, even after doing the above?

If, even after you change the permissions of the file, the problem still exists, then it might be possible that your user (or Apache) doesn’t have the right permissions to make those permissions changes (we know, we’re using the word permission abundantly in this post!). In this case, you should delete the file and then re-create it from a guaranteed-to-be-working backup. In order to do that, you will need first to grab, from Joomla’s official website, a clean copy of the exact Joomla version that you’re using.

Now, if you’re able to see the index.php, then all you need to do is to delete it and then re-upload it from the clean copy of Joomla that you’ve just installed. If you’re not able to see the index.php file, then you’ll first need to write a small PHP script to unlink (delete) the file from the website before uploading the clean index.php that you have.

Which versions of Joomla have this problem?

We have noticed that not all versions of Joomla have this problem. In fact, the versions affected are Joomla 1.5 builds that are less or equal to 15 (e.g. Joomla 1.5.0 until Joomla 1.5.15).

But what is the root cause of the problem?

There are two things that might cause this issue:

  1. A malicious attack on the website exploiting the many vulnerabilities of old Joomla 1.5 builds.
  2. Some poorly written (and legacy) extensions that behave erratically under some conditions.

What is the long term solution to the problem?

There are two long term solutions to the problem:

  1. Upgrading the Joomla website to the latest version, which ensures that the website is kept up-to-date with the latest patches.
  2. Locking write activities on the Joomla website by switching to DSO. This is a good option in case you cannot afford an expensive migration.

We hope that you found this guide useful. Now, if you’re having the same problem and you’re not able to fix it by following our guide, then feel free to contact us. We’re always read to help, our rates are affordable, and we are the friendliest developers on this planet (seriously, try us!).

2 Responses to ““Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0” Error in Joomla”
  1. Comment by Akashdeep — March 17, 2015 @ 1:53 am

    In my case the home index.php display fine…

    But when I upload a PHP file to opt/lampp/htdocs/ and try to execute the file I get the line 0 error. What could be the problem?

  2. Comment by Fadi — March 19, 2015 @ 8:24 pm

    Hi Akashdeep,

    It seems that Apache cannot execute files uploaded by the user you’re using to FTP files with. That’s technically the same problem described in the post. You should change the ownership of that file to be the same as the ownership of, say, the “index.php” file.

Leave a comment