A web developer’s diary

March 12, 2007

Permission denied in Unknown on line 0

Filed under: PHP — Bindu @ 6:26 am

ErrorType:

Warning: Unknown(somephpfile.php): failed to open stream: Permission denied in Unknown on line 0.

I wonder who writes error messages for the PHP development team. Some state-of-the art professional or a poet!! Only he can understand what this error means.

Solution:
When my php script threw the same message, I looked into the file permissions of this file and saw that it had only read/execute permissions for the owner. This error disappeared when I gave permissions for Group and Everyone.

(Note: There are different kinds of Permission denied error in PHP. Your problem might not be due to this reason. However, it doesn’t hurt to look into the permissions of the corresponding file. If you think that I could help, please leave a note here.)

About these ads

89 Comments »

  1. Thank you so much for this… I ve been looking for this solution for 2 full days! Also reconsidered reinstalling Ubuntu with the Server option!

    Comment by Walmik — March 20, 2007 @ 5:12 pm | Reply

  2. Just installed Apache Php Mysql in my Linux Fedora Box a while back, and ran into the same problem. So, I googled and found this page. A life saver! Thanks.

    Comment by Ahsan — March 28, 2007 @ 3:28 pm | Reply

  3. Thanks too this made me use xp instead of My Ubuntu for PHP for a day

    Comment by ASD — October 13, 2007 @ 3:22 pm | Reply

  4. The answer i was looking for.
    Thanks

    Comment by Jose — November 6, 2007 @ 2:24 pm | Reply

  5. Thnx very much for that solution… that’s perfect! Good work!

    Comment by Acácio — November 30, 2007 @ 7:16 pm | Reply

  6. Thanks, I think I wouldn’t think of that one… Thanks… lost one day fixing this trouble….

    Comment by Andrej Pintar — February 1, 2008 @ 9:41 am | Reply

  7. I have been having this problem for at least one week and my effort has gone in vain.

    I’ll see if it is the file itself that need chmoding as the folder is ok.

    I think I’m saved.

    Thanks a lot!

    Comment by banago — February 7, 2008 @ 2:22 pm | Reply

  8. Gracias, problema solucionado

    Comment by Eduardo — February 7, 2008 @ 9:26 pm | Reply

  9. I did resolved the problem too. My files needed chmoding. Thanks again!

    Comment by banago — February 8, 2008 @ 2:39 pm | Reply

  10. Ohhh gosshhh!! It works!! :)

    thx millions :D

    Comment by Seeker — February 15, 2008 @ 5:04 pm | Reply

  11. Thank you!

    Just installed ubuntu LAMP box (no gui). Installed phpmyadmin, then sent some files from my Windoze machine only to get this frustrating error message.

    Did a chmod -R (my web directory) 777 and everything’s fine! :)

    Thank you again!!!

    Comment by Dave — May 19, 2008 @ 9:47 am | Reply

  12. Ran into this problem and you made my life easier. Figured I’d leave my mark to show just how useful your little explanation is as it continues through the years!

    Comment by Nathan Beadle — June 3, 2008 @ 5:11 pm | Reply

  13. Life saver , if the error was just a little clearer it would have been an easy fix.

    Comment by djdrastic — June 12, 2008 @ 1:14 pm | Reply

  14. Thanks. Really worked for me.

    Comment by jose — June 23, 2008 @ 5:50 pm | Reply

  15. In my Ubuntu you have to write it like this:

    chmod -R 0777 my_web_directory

    Comment by Kid Walker — July 14, 2008 @ 6:41 pm | Reply

  16. Thanks this helped! spent too much time trying to figure it out, this may be obvious to everyone else, but wasn’t to me, so it might be worth mentioning, but you may also have to change the permissions of the files themselves if they were put in before the folder permissions were changed.

    Comment by Justin — July 18, 2008 @ 2:30 pm | Reply

  17. Arrghh ;-) I had this problem in the past, but I forget what was the solution and of course that problem occured again. But this time I found your post. Thank you very much.

    Comment by Arpad — July 22, 2008 @ 11:15 pm | Reply

  18. Just gonna throw it out there, in a multi-user environment, or any server on the internet, using 777 permissions on all of your files is a bad idea, unless you actually want everyone reading and writing all of your files. I would look into changing ownership and/or the group of the file first for security reasons.

    Comment by Max — July 23, 2008 @ 5:48 am | Reply

  19. Thank u very much for the post…

    Comment by Shaaa — September 5, 2008 @ 10:28 am | Reply

  20. You are a saviour man i’ve been on this for more than 12 hrs everything was setup and i was wondering why is the page not loading.
    finally i set the permissions and the phpinfo page loaded.

    thanks bro

    Comment by Vish — November 8, 2008 @ 12:18 pm | Reply

  21. Hi…

    I Don’t know who wrote this soluton.Anyway it helped me a lot…For me this error message appeared suddenly..and when I change the permissions it worked..Thanks a lot

    Comment by Alwin — November 13, 2008 @ 7:35 am | Reply

  22. This fixed my problem; Thank You!!! Merry Christmas!

    Comment by Joe — December 18, 2008 @ 6:04 pm | Reply

  23. Thanks for pointing out the solution to this particular error.

    I’ve been having this error with PHPMaker 6-generated scripts but with your (easy) fix, everything is now running smoothly.

    Comment by Claude Gelinas — December 19, 2008 @ 4:44 am | Reply

  24. You saved my life…. I was going nuts … thanks man!

    Comment by salman — January 29, 2009 @ 1:19 pm | Reply

  25. I think the problem is that the file should have atleast 0444 permission meaning atleast read permission for others. if the file does not have read permission for others you won’t be able to run your scripts. However, you do not need to apply 0777 permissions only chmod 0444 should work. Thanks again.

    Comment by salman — January 29, 2009 @ 1:28 pm | Reply

  26. [...] Permission denied in Unknown on line 0 [...]

    Pingback by Permission denied in Unknown on line 0 | Consulente di informatica a Roma — February 13, 2009 @ 12:40 pm | Reply

  27. I used chmod a+rw info.php and then it worked.
    Thanks!

    Comment by Matt McGinty — February 17, 2009 @ 7:54 pm | Reply

  28. Correction:

    I used chmod a+rx info.php

    Comment by Matt McGinty — February 17, 2009 @ 7:55 pm | Reply

  29. I Was really starting to get annoyed with the error!
    Many many thanks for the valuable help…

    Cheers

    Comment by Patricio — April 1, 2009 @ 9:39 pm | Reply

  30. You sir are the master … thank you. Stupid error message.

    Comment by Darrell — May 11, 2009 @ 8:13 am | Reply

  31. Why is the error message stupid? The file permissions are wrong and it gives this error message when PHP doesn’t have permission to read the file. How is PHP supposed to give you specific error details when it has absolutely no way of reading the problem…

    I must have set my index file to 0200 during my sleep or something. Strange.

    Comment by Gibbs — May 22, 2009 @ 7:12 am | Reply

  32. Thank you for the solution. Kind of hard to figure out actually.

    Comment by Adam — June 6, 2009 @ 4:23 pm | Reply

  33. Thanks a lot! This saved me from a lot of trouble.

    Comment by Alex — June 15, 2009 @ 10:37 am | Reply

  34. I feel as thick as bricks, but yea it works.
    I was sure I had chmod a+rx, but must have forgot to press enter :)

    Comment by bill — July 15, 2009 @ 1:24 pm | Reply

  35. I did upload php file using a ftp client, I did overlooked the uploaded file permissions as I thought it will be 0644 by default, but after I read this, I did check and found that it was uploaded with 0600 permission. it worked after changing permissions to 0644, thank you

    Comment by securitywonks — July 21, 2009 @ 9:03 am | Reply

  36. Thank you for your explanation. I was stunned by the inexpressive error.
    Now all is well.
    Cheers

    Comment by mihai — September 16, 2009 @ 12:55 pm | Reply

  37. I had this problem and my permissions were fine. Checking /var/log/messages revealed that SELinux was preventing my file from being accessed by apache because it was mislabeled. Running the following command on the offending file solved my problem:

    chcon -t httpd_sys_content_t myfile.php

    This happened when I created a php file in my home directory then moved it to my docroot. To see the labels of any file, use

    ls –scontext

    Hope that helps.

    Comment by John — September 18, 2009 @ 2:48 pm | Reply

  38. Thanks Mate.
    You saved my life.

    Comment by Farrukh — November 2, 2009 @ 2:15 pm | Reply

  39. Thanks for the quick fix, I was skeptical about permissions too. Plus, it threw error about “function.include not found” and I started looking for errors in the code and started find command to look for function.include file.

    Comment by SQ — November 4, 2009 @ 5:29 pm | Reply

  40. Hey, I’m using Xampp on MAC as my server and get the same error. I can’t seem to find anything about permission anywhere on this. Can you please enlighten me and tell me where to go and what to do.

    Thanks alot!!

    Comment by ED — November 4, 2009 @ 6:33 pm | Reply

  41. Thanks a lot! Quick solution for annoying error :)

    Comment by Lars — November 13, 2009 @ 9:44 pm | Reply

  42. Thanks a lot. It really helped

    Comment by Hind — December 3, 2009 @ 6:36 am | Reply

  43. Thanks for the solution, understanding this helps to move along the PHP learning curve!

    Comment by 30south — December 21, 2009 @ 3:56 pm | Reply

  44. Thanx a lot!

    Comment by Erica Roberts — January 13, 2010 @ 8:56 am | Reply

  45. Thanks a lot!
    You really help me out! :D

    Comment by Rizkydaya Aditya Putra — March 1, 2010 @ 9:08 am | Reply

  46. I thank God for the answer i got from this site. May God bless you. I have been in this error for more than 2 weeks. Thank! for the solution you gave me

    Comment by Ugwu Samson — April 6, 2010 @ 4:26 pm | Reply

  47. Command:

    sudo chmod -R 777 /var/www

    that works fine, :D

    Comment by Jesse — April 10, 2010 @ 9:43 pm | Reply

  48. Oh, people… please…. it’s 2010. Making an entire webroot world-writable is such a dangerous thing to to do. It just invites defacement and malicious file hosting on your servers.

    Do it the right way:

    chmod -R +X,u+rw,g+rx,o-rw,a+rx /web/directory/root

    This will give you (safe) perms like this:

    drwxr-xr-x. 2 owner owner directory
    -rwxr-xr-x. 1 owner owner script.php

    But, dir permissions are not what are causing me to get this error.

    Comment by Greg Stewart — April 12, 2010 @ 1:55 pm | Reply

  49. Thanks a lot.
    I’ve been working on this problem for a week until i found this thread.
    Now it occurs to me that i made the file on a windows system and transferred it to Mac. So Mac users didn’t have the permissions.
    Thanks thanks thanks

    Comment by Ike — April 24, 2010 @ 10:17 am | Reply

  50. If you are a real estate professional, be really careful in dealing with KoRes Corp. in Weston Florida. Tulio Rodriguez & Monica Cataluna-Shand are shysters and look for anyway to steal ones customers. They attempt to steal your client by requesting their contact information and later contact them behind your back to get them to deal with them directly.

    Comment by Ontothempopor — May 4, 2010 @ 9:55 am | Reply

  51. Its ok that my name will appear at bottom of the page, still thanks for this solution. :-)

    Comment by SanTri — May 14, 2010 @ 12:34 pm | Reply

  52. Haha. very true!
    But thanks for that info. Was stuck with that cryptic error message for sometime now.
    I thought it was because of my upgrading apache.

    Comment by Ganesh — July 5, 2010 @ 1:47 am | Reply

  53. Fixed my problem too! Thanks!

    Comment by Abel — July 7, 2010 @ 5:46 pm | Reply

  54. It worked. Thx.

    Comment by Eliathan — September 23, 2010 @ 8:22 pm | Reply

  55. Thanks. saved lots of time!

    Comment by paras — December 30, 2010 @ 7:51 pm | Reply

  56. I just want to point out you have a spammer on your blog by the name of “Ontothempoper”. Also, great solution. Unfortunately I do not have administrative access to the server so this pretty much renders this solution useless unless I ask the admin to grant permission.

    Comment by Montana — January 4, 2011 @ 1:42 pm | Reply

  57. Hey, Thank you so much.
    This has solved my problem too…

    Comment by pavan — January 9, 2011 @ 9:26 am | Reply

  58. “Little things, great effects”
    This has solved my problem too…
    Tnx’s

    Comment by ignorante primero — February 9, 2011 @ 5:41 pm | Reply

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

    Fatal error: Unknown: Failed opening required ‘C:/xampp/htdocs/sand_box/databases.php’ (include_path=’.;C:\xampp\php\pear\’) in Unknown on line 0

    Comment by Nour — February 27, 2011 @ 9:39 pm | Reply

  60. Yep, that was it.

    Comment by Peyote Short — April 13, 2011 @ 3:45 pm | Reply

  61. Wish I could have found this sooner! worked like a charm. I now have my FTP client setup to change the permissions on upload!

    Comment by Kielbasa — June 5, 2011 @ 5:19 am | Reply

  62. Change the permition chmod 644 to the file is presenting the error –> /opt/lampp/htdocs/xampp/proyect/file.php

    Comment by kurokysan — June 14, 2011 @ 8:34 pm | Reply

  63. From the Google results list, it looked like you called your whole diary Permission denied in Unknown on line 0 – which I thought was funny. You solved my problem thanks!

    Comment by hotcalf — August 11, 2011 @ 10:09 pm | Reply

  64. Muchas gracias…;)

    Comment by Victor Cordova — August 14, 2011 @ 10:33 pm | Reply

  65. I have tried changing permissions on phpinfo.php to 777 via Filezilla and it did not work.
    Is this the way to do it?
    Is this the file to change permissions?
    In my case the file was inside folder /public.
    Please advise.
    Thanks
    Joni

    Comment by Joni — September 9, 2011 @ 9:15 pm | Reply

  66. works like magic.. thank you :)

    Comment by Chams — December 22, 2011 @ 2:27 am | Reply

  67. thank you :-D You save me a some debugging time :)

    Comment by IvanK — December 28, 2011 @ 10:03 pm | Reply

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

    Fatal error: Unknown: Failed opening required ‘/home/protechs/public_html/index.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in Unknown on line 0

    Comment by transformer — June 1, 2012 @ 6:35 am | Reply

  69. I move a site to a new host and I was working on it; editing pages and style sheets. Then After 4-5 hrs it went down for two days now.

    when you visit the site , it displays this err :

    [

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

    Fatal error: Unknown: Failed opening required ‘/home/protechs/public_html/index.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in Unknown on line 0

    ]

    we call the tech support guys @ the web host company but, we didn’t hear anything from them for two days now. Any idea what should be done to fix it?
    thanks

    Comment by transformer — June 1, 2012 @ 6:41 am | Reply

  70. How to fix this err?

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

    Fatal error: Unknown: Failed opening required ‘/home/protechs/public_html/index.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in Unknown on line 0 ”
    Site down for 5 days cuz of that err!

    Comment by transformer — June 1, 2012 @ 7:10 am | Reply

  71. plis help me, i have problem when access phpmyadmin
    erros message :

    Access forbidden!

    New XAMPP security concept:

    Access to the requested object is only available from the local network.

    This setting can be configured in the file “httpd-xampp.conf”.

    If you think this is a server error, please contact the webmaster.

    Error 403

    10.2.117.154
    Apache/2.4.2 (Unix) OpenSSL/1.0.1c PHP/5.4.4

    how to fix this??

    Comment by iqbal — August 1, 2012 @ 2:52 am | Reply

  72. I just can’t tell you how much relieved I am getting this piece of info. It brought an end to my day-long search for this solution. Where all else failed, this worked!
    Thanks a bunch!

    Comment by Gzux — July 13, 2013 @ 8:20 pm | Reply

  73. Sometimes the working of the Private Detective Denver. For
    example, if you are trying to reach is not working.
    Scroll down for videoAccording to his acquaintances who spoke
    to 48 Hours Mystery, the women said they were unaware of the illegal activities carried
    out in one sitting. There’s technically no” best” ELO rating, but if it hasn’t happened yet, you’d like to know how to get the target to do something extra to protect and maintain the intellectual properties.

    Comment by http://Investigations.com/ — August 17, 2013 @ 5:55 pm | Reply

  74. I think this is among the most important info
    for me. And i’m glad reading your article. But should remark on some general things,
    The site style is ideal, the articles is really great : D.

    Good job, cheers. Products in order to how to get views on youtube, we could
    assist you!
    buy youtube subscribers Low-cost and Protect regarding youtube
    account.

    Comment by how to get views on youtube — March 16, 2014 @ 11:09 pm | Reply

  75. I have fun with, result in I discovered exactly what I was having a look for.
    You have ended my four day lengthy hunt! God Bless you man.

    Have a great day. Bye. facebook like in facebook Protected and straightforward from most significant facebook likes company.

    If you would like buy likes towards your facebook account, there are many
    extremely effective approaches.
    buy usa facebook likes Lowest Selling prices Ideal Support.

    Comment by facebook like — March 23, 2014 @ 3:11 pm | Reply

  76. Excellent keen synthetic eyesight pertaining to details and can
    foresee difficulties before these people take place.

    Comment by Bernardo — April 13, 2014 @ 6:24 pm | Reply

  77. I have an excited analytical attention regarding details and may anticipate complications before
    these people happen.

    Comment by 辦公椅 — April 15, 2014 @ 5:33 am | Reply

  78. Whats up! I simply want to give a huge thumbs up for the good information youve here on this
    post. I will probably be coming again to your blog
    for more soon.

    Comment by SEO — April 18, 2014 @ 2:25 am | Reply

  79. Hi everybody, here every person is sharing these experience, therefore it’s fastidious to read this web site, and I used to
    pay a visit this blog everyday.

    Comment by LED-Treiber — April 19, 2014 @ 11:14 am | Reply

  80. I love to disseminate knowledge that will I have accrued with the yr to help improve team performance.

    Comment by Holika Holika — April 22, 2014 @ 12:12 pm | Reply

  81. Good day! I just want to give a huge thumbs up for the good
    information youve right here on this post.
    I can be coming again to your blog for more soon.

    Comment by 電動機車 — April 23, 2014 @ 10:06 am | Reply

  82. Bruv…..ure a life saver! I have not worked an app for a week because of this misleading php log. Thanks mate!!!

    Comment by tonyjonah — June 7, 2014 @ 2:30 am | Reply

  83. Pensiuni Vatra Dornei

    Excellent beat ! I would like to apprentice while you amend your website, how can i subscribe for
    a blog website? The account helped me a acceptable deal.

    I had been tiny bit acquainted of this your broadcast offered bright clear idea

    Comment by Cazare Herculane Piscina — June 30, 2014 @ 3:08 pm | Reply

  84. I’m pretty pleased to uncover this web site. I
    need to to thank you for ones time just for this fantastic read!!
    I definitely loved every part of it and i
    also have you book marked to check out new
    stuff on your site.

    Comment by apk extractor download — July 8, 2014 @ 7:21 pm | Reply

  85. Thanks for some other wonderful post. The place else may jut anybody get that typ of info
    in such a perfect method of writing? I have a presentation next week, and I am at
    the look for such info.

    Comment by acupuncture Services california — August 4, 2014 @ 12:06 am | Reply

  86. Can you tell us more about this? I’d love to find
    out some additional information. youtube
    youtube

    Comment by youtube — September 19, 2014 @ 5:16 am | Reply

  87. Awesome things here. I am very satisfied to look your article.
    Thank you so much and I’m having a look forward to contact you.
    Will you please drop me a e-mail?. youtube
    youtube

    Comment by youtube — September 20, 2014 @ 7:27 am | Reply

  88. Spot on with this write-up, I absolutely feel this amazing site needs
    a great deal more attention. I’ll probably be
    returning to read through more, thanks for the info!
    instagram
    instagram

    Comment by instagram — September 26, 2014 @ 4:05 pm | Reply

  89. Hi i am kavin, its my first time to commenting anywhere, when i read this post i thought
    i could also make comment due to this brilliant paragraph.

    Comment by tai lieu on thi dai hoc mon sinh — October 3, 2014 @ 2:54 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: