Post Date: October 12, 2017
Last Updated: September 17, 2026
Introduction
While configuring Apache 2.4 on a Linux server, you may encounter the following error in the Apache error log:
Client denied by server configuration
This error generally indicates that Apache is preventing access to the requested directory because the document root has not been explicitly allowed in the Apache configuration.
For example, if a website uses the following document root:
/home/domain/public_html
Apache may deny access unless the directory is permitted in the VirtualHost configuration.
This guide explains how to allow access to the document root and resolve the error.
Prerequisites
Before making the changes, make sure you have:
- A Linux server.
- Apache 2.4 installed and running.
- Root or sudo access.
- An existing Apache VirtualHost configuration.
- The document root path used by the website.
For this example, we use:
/home/domain/public_html
and assume the Apache VirtualHost configuration is:
/etc/apache2/sites-enabled/domain.conf
Understanding the Error
The error:
Client denied by server configuration
usually occurs when Apache’s access-control rules do not permit access to the directory being requested.
Apache 2.4 uses the Require directive for access control. Therefore, the document root needs an appropriate <Directory> configuration.
Implementation
Step 1: Open the Apache VirtualHost Configuration
Open the VirtualHost configuration file:
vi /etc/apache2/sites-enabled/domain.conf
Locate the existing VirtualHost configuration and add a <Directory> block for the website’s document root.
Step 2: Allow Access to the Document Root
Add the following configuration:
<Directory "/home/domain/public_html">
Require all granted
</Directory>
The complete VirtualHost configuration may look similar to:
<VirtualHost *:80>
ServerName domain.tld
ServerAlias www.domain.tld
DocumentRoot /home/domain/public_html
<Directory "/home/domain/public_html">
Require all granted
</Directory>
</VirtualHost>
The Require all granted directive allows Apache to serve content from the specified directory.
Step 3: Verify the Apache Configuration
Before restarting Apache, check the configuration for syntax errors:
apachectl -t
If the configuration is correct, you should see:
Syntax OK
If an error is reported, correct the configuration before applying the changes.
Step 4: Restart Apache
Restart Apache to apply the configuration:
service apache2 restart
On systems using systemd, you can also use:
systemctl restart apache2
Step 5: Test the Website
Open the website in a browser:
http://domain.tld
If the <Directory> configuration was the cause of the issue, Apache should now be able to serve the website content from:
/home/domain/public_html
Troubleshooting
If the error continues after adding Require all granted, check the following:
Check the Document Root
Make sure the configured DocumentRoot matches the actual website directory:
DocumentRoot /home/domain/public_html
Check the Directory Path
Make sure the <Directory> path matches the document root exactly:
<Directory "/home/domain/public_html">
Require all granted
</Directory>
Check Apache Configuration
Run:
apachectl -t
Check Apache Error Logs
Review the Apache error log for additional information:
tail -f /var/log/apache2/error.log
Depending on the VirtualHost configuration, the website may also have its own error log.
Conclusion
The Apache 2.4 error “Client denied by server configuration” commonly occurs when Apache’s access-control configuration does not allow access to the website’s document root.
Adding an appropriate <Directory> block with:
<Directory "/home/domain/public_html">
Require all granted
</Directory>
allows Apache to serve content from the specified document root.
Always validate the configuration with apachectl -t before restarting Apache.
Frequently Asked Questions
1. What does “Client denied by server configuration” mean in Apache?
It means Apache’s configuration is preventing the client from accessing the requested resource. One possible cause is that the website’s document root has not been allowed through a suitable <Directory> rule.
2. What directive is used to allow access in Apache 2.4?
Apache 2.4 uses the Require directive. For example:
Require all granted
allows access to the configured directory.
3. Do I need to restart Apache after changing the configuration?
Yes. After validating the configuration, restart or reload Apache so that the changes take effect.
apachectl -t systemctl restart apache2
4. Why is the <Directory> path important?
The <Directory> path must match the actual filesystem location of the website’s document root. If the paths do not match, the intended access rule may not apply.
5. Does this error always mean the <Directory> directive is missing?
No. A missing or restrictive <Directory> rule is one common cause. Other Apache access-control rules, filesystem permissions, .htaccess settings, or security modules can also result in access being denied.
Related Articles
- How to Install Apache Superset on Ubuntu via Docker Compose
- How to Configure Apache with PHP-FPM handler in ubuntu 20.04
Talk to our experts
Have a technology challenge or looking for the right solution for your business? Our team can help you with cloud, DevOps, development, infrastructure, design, and more. Feel free to reach out to our experts here.