How to Fix mod_authz_host Apache Errors in Linux

When installing the apache2 service on Red Hat Enterprise Linux, Arch, Scientific Linux, Debian Server, Ubuntu Server or any of the other distributions that support it, you might find that you get an error about the mod_authz_host module that prevents the execution of the service. You’d likely find this error to be a problem any time you restart the apache2 service. This error usually comes in the form of a syntax warning about the first line of the  file, but you could theoretically get some different error.

Regardless of which line you might have trouble with, the fix has little to do with mod_authz_host not being installed or even loaded in RAM. In fact, if you’re getting this error it means that the apache2 server service is correctly loading the  module. The problem merely has to do with the fact that a directive is out of place somewhere, and rearranging the code should fix your problem quite quickly. Please note that you will occasionally see instructions to install mod_authz_host in apache2, which is irrelevant to this discussion. Your errors don’t come from a lack of a specific package nor do they come from any sort of unfulfilled dependency. The way the developers elected to phrase these errors lead to these common misconceptions.

Correcting the restrict.conf Module Directives

For the sake of discussion, we’ll use the Linux distribution encyclopedia at for our examples. The official apache2 documentation uses as an example, and in any case, you won’t want to use either of these addresses.

Open the  file with a text editor. Since this is in a protected directory, you’ll need to have root access. We used , but you could also use vi or another text editor you prefer. You don’t even necessarily have to use a console editor, but make sure to use gksu instead of sudo if appropriate to do so.

Once you’ve loaded the file, pay close attention to something that reads, for example:

Order deny,allow

Deny from all

Allow from

This text should only exist inside of <Location /> </Location> blocks. Note the space in the first tag. If you have that line of text floating around outside of any blocks, either add tags around it or move it so that it reads as such:

<Location />

    Order deny,allow

    Deny from all

    Allow from


Remember that you’ll need to replace with the actual URL you’re working with. If you find any lines that reference directly, then you’ve either copied them directly from example code or they’re added by default. The domain merely exists for illustration in technical documents and serves no real purpose. The official documentation at does indeed reference them. You can probably safely remove these when you add the new text in.

Should you ever need to include a directory in your restrict.conf file, then you could replace <Location /> </Location> tags with <Directory /> <Directory> tags, but you need to make sure to maintain the space in the first tag once more. Make sure to save the document and then close it before restarting the apache2 service. You shouldn’t have any further problems from here on out.

This is what the apache server means when it returns an error something like:

The actual error would have a line number in place of the octothorpe, but it’s indicating that the directives aren’t safely enclosed inside of said tags. You may wish to navigate directly to the line given in the error when debugging the script to check what’s wrong with it. While the error in question will tell you that the Apache error log may have more information, it will probably merely reinforce the same concepts discussed here.

Future syntax errors can be corrected in a similar fashion. You might find that after fixing that one, the apache2 service spits out another error. This is normal, as strange as that might sound because it only executes code up until the first line it finds a problem with. If there were problems further down the line, then it would have never got to them. Should you have any such issues, then pay close attention to the line number when editing the  file. If you’re using nano to edit the file, then you can always hold down the Ctrl key and push the C key to find which line your cursor is currently on. This will make the debugging process go much more smoothly.

You might find that you have multiple blocks floating around in such a manner that aren’t attached to anything. Each of these need to have tags on them. Remove the extra blocks anytime that you find you have multiple copies of the same URL with the same exact directives since these duplicates can potentially cause problems. You generally only ever need to have a single copy of any specific URL, since you shouldn’t pass additional directives about one to the apache2 server as they might ultimately countermand one another.

Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Expert Tip

How to Fix mod_authz_host Apache Errors in Linux

If the issue is with your Computer or a Laptop you should try using Restoro which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Restoro by clicking the Download button below.

Download Now

I'm not interested