Ubuntu 22.04 Apache – 403 Forbidden You don’t have permission to access this resource

I tried to access my internal website using http://localhost but I got error of:

I am able to access the website via 127.0.0.1

I have checked my files access and all is good.

Solution

ubuntu 22 apache2 localhost able to access now
ubuntu 22 apache2 localhost able to access now

1. Edit your default.conf add localhost as ServerAlias (sudo nano /etc/apache2/sites-enabled/default.conf)

2. Edit your hosts as below (sudo nano /etc/hosts/)

3. Restart Your Apache2 server