You don’t have permission to access http://localhost files or folders on this server in Ubuntu (Linux)

If you are getting the following error while browsing any local website in Ubuntu like:

You don’t have permission to access http://localhost on this server files or folders

then you may not be having the full rights to access that folder or file(s). On the other end, you may be accessing the folders and files through the File Browser (while using gnome-terminal command sudo nautilus etc), but while browsing them through any web browser like Firefox etc., you may be getting the permissions error as mentioned:

403 Forbidden

You don’t have permission to access http://localhost on this server (or any of localhost’s subdirectory)

Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.5 with Suhosin-Patch Server at localhost Port 80

For the solution, simply do the following method to grant yourself and all of the users, including admin, groups and other users, the read, write and execute rights, to stop getting such errors:

Goto Applications -> Accessories -> Terminal

and write the following code:

chmod a+rwx foldername or filename

with full path, for example:

Granting Rights on Folder:

If you are getting such error on the directory:

then the command should be:

chmod a+rwx /var/www/webtechquery/
chmod a+rwx /var/www/webtechquery/*

Granting Rights on File:

If you want to grant full rights on files e.g. abc.php, then the command should be:

chmod a+rwx /var/www/webtechquery/abc.php

If you want the rights to be granted to only the owner, group or specific user(s), then use the following commands:

For Owner:

chmod o+rwx /var/www/webtechquery/abc.php

For Group:

chmod g+rwx /var/www/webtechquery/abc.php

For User:

chmod u+rwx /var/www/webtechquery/abc.php


o = owner
u = user
g = group


r = read
w = write
x = execute

  1. Hey, I’m also new to ubuntu.
    I try to install apache2, mysql and php5… But when I try to access /localhost it gives me the 403 forbidden error.
    I already tried to re-install apache2, however, the error still happens. When I try to access /var/www/index.html the
    page loads and it says “It works” but when I try to access localhost, forbidden errror is displayed.
    Any suggestions?

  2. Neither changing the /etc/apache2/sites-available/default file to my real folder WWW in my home directory !!

    But my real WWW has 777 permisions, with chmod -R 777 www

    Any idea !

  3. UPDATE !

    If i paste my entire WWW into /var it’s works, only with the softlink doesnt work !

    Any idea ! maybe is a basic thing but i cant find a good solution.

  4. Any idea?

    I have the /var/ww directory with 777 and it works !

    But when i paste in /var the softlink to my www in my home doesnt work ! and the link www has the 777 and all the directory in my home has 777

    thanks in advance !

  5. Thanks, but this didn’t work for me. It changed the permissions, but it didn’t fix the 403 error I’m getting. (and yes, I chown’d it so www-data group has access). I’m very perplexed.

  6. Hey,i changed the permissions but i still get the error.I copied a folder to the www directory,and the tried to acess its content via localhost and got the error.Someone help.

  7. Hey there, this was pf very much help my friend,
    but for some reason i am only able to grant permissions to the files within the main files and not the files within the subfiles, so it ends up working sorta half way.
    Or not working at all as you can imagine if i’m using a CMS of some sort…
    Any suggestions on how to fix that?
    thanx ahead of time! :)

  8. Hai,

    I am new to Ubuntu Server 9.10. I am running a web server in Ubuntu. I want to make my webserver more secure. Can you suggest me the way to webserver more secure ?


    Jithin k

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>