macOS Forbidden 403, You don’t have permission to access /~username/ on this server

In macOS if your user personal or document web sharing is not working for a user and is generating a Forbidden 403 error but is OK at the other document root localhost level, the issue may be a configuration file for the user.

The higher document root level of http://localhost/ displays “It Works” but when going to the user level, http://localhost/~username/ you get the:

Forbidden 403, You don’t have permission to access /~username/ on this server

Check that you have a “username.conf” filed under:

/etc/apache2/users/

If you don’t, then create one named by the short username of the account with the suffix .conf:

Find your short username by typing in the Terminal

whoami

Change directory into the right directory:

cd /etc/apache2/users

sudo nano username.conf

Check Apache version

httpd -v

For macOS Apache 2.2

Then add the content below swapping in your username:

<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

For macOS Apache 2.4

Then add the content below swapping in your username:

<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>

Permissions on the file should be:

-rw-r--r--   1 root  wheel  298 Jun 28 16:47 username.conf

Restart apache

 sudo apachectl restart

Then all should be good.

Changing The Apache Web User

One of the frustrations of using the Users/username/Sites folder is the permissions issues with things like updates and authentication.

This is because the default webserver user which runs httpd is known as _www, which will not be the user in your local account. If your machine is only in use by you and the webserver will run only under your account then you can change the user and group values to your name and group, that way there will be less permission errors.

Find and change this  in /etc/apache2/httpd.conf

sudo nano /etc/apache2/httpd.conf

Macos User Group Apache

Find:

User _www
Group _www

Change to:

User usershortname
Group staff

 

Just change it to your short username and group, group will be staff and restart Apache

 sudo apachectl restart

5 Comments

  1. Zebue on May 15, 2023 at 3:22 am

    Changing User and Group worked like magic. Thanks

  2. ck on October 28, 2022 at 6:03 pm

    not work for os x monterey

  3. Mark on July 19, 2022 at 2:56 am

    Thanks buddy, it works!

    I’ve tried many ways to solve this problem, the problem is here : `User _www Group _www`

  4. David on October 26, 2021 at 12:43 pm

    Ditto, not working. I’ve been tinkering for a couple of weeks and nothing wants to give me access.

  5. Gabri Botha on October 12, 2021 at 4:19 pm

    Does not work for me on Big Sur 11.6

Leave all Comment