Ugacomp

Could not reliably determine the server’s fully qualified domain

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM

CLOUD VPS M

$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM

CLOUD VPS L

$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

The Apache server isn’t immune to errors and issues. So, the error: “Could not reliably determine the server’s fully qualified domain name” in Apache usually pops up when the server is unable to figure out its own fully qualified domain name (FQDN).

Let me break this down for you in a more beginner-friendly way;

Think of a fully qualified domain name (FQDN) as the complete and precise address of your server on the internet. It includes the hostname and the domain name, like “www.ugacomp.” When Apache starts, it wants to know its own FQDN, but sometimes it can’t figure it out automatically. That’s when you see this error.

The inability of the Apache server not to figure out the required fully qualified domain name could be attributed to several issues that we would like to break down in this guide:

Missing ServerName directive

The ServerName directive in Apache configuration is like a label identifying which website should be served for a specific domain name or IP address. It’s crucial to have multiple websites on the same server, ensuring users see the intended website based on the URL they enter.

The most common cause of this error is a missing ServerName directive in the Apache configuration file. This directive explicitly tells Apache what domain name it should use for the current virtual host. Without it, Apache tries to guess the domain name based on various factors, which might not be reliable

Test the Apache configuration for syntax errors

To identify if the ServerName directive is missing in the Apache configuration file, you need to run the following command on your server terminal:

sudo apachectl configtest

If there are no syntax errors, the command will output the following message:

Syntax OK

If there are syntax errors, the command will output a message that includes the line number and a description of the error. For example, syntax error on line 10 of /etc/apache2/sites-available/your_site.conf: Invalid command ‘FooBar’, perhaps misspelled or defined by a module not included in the server configuration

RECOMMENDED READING: How to troubleshoot Apache “Connection refused” error?

How to fix the missing ServerName directive

This can be done by editing the main Apache configuration file, which is usually located at the following directory path:

/etc/apache2/apache2.conf

If your server setup is using the Virtual host configuration files, then you have to look through any of the following directory paths:

  • Look through the sites-available at this path:
/etc/apache2/sites-available/
  • Look into sites-enabled located at this path:
/etc/apache2/sites-enabled/

It’s important to note that the Apache configuration file governs the overall environment of the web server, while virtual host files provide customized settings targeting individual websites hosted on the system. In other words, if you want your Apache setup settings to be global, affecting all sites hosted on the system, then you have to use the apach2.conf file in this case.

RECOMMENDED READING: How to deploy WordPress on a Ubuntu LAMP Server

Let’s add the missing ServerName directive in the apache2.conf file, which will make the settings global, affecting all websites or applications hosted on the server. Here is the syntax you need to use:

ServerName <your_server_name>

From the above syntax, you need to make sure <your_server_name> is replaced with your domain name or subdomain. Let’s assume the domain name you want to use is ugacomp.com, then your apache2.conf file with the ServerName directive defined should be set up as follows:

# Sample Apache configuration file

# Global configuration

ServerTokens OS
ServerSignature Off

# ServerName directive
ServerName ugacomp.com

# Default settings
<VirtualHost *:80>
    # ServerAdmin directive
    ServerAdmin [email protected]

    # DocumentRoot directive
    DocumentRoot /var/www/html

    # Directory settings
    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    # ErrorLog and CustomLog directives
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
</VirtualHost>

In case you’re using the virtual host file other than apache2.conf file, then we can add the ServerName directive as seen below:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName dash.ugacomp.com
    DocumentRoot /var/www/html/your_website_directory

    <Directory /var/www/html/your_website_directory>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
</VirtualHost>

Conflicting ServerName declarations

One of the potential causes of this error: “Could not reliably determine the server’s fully qualified domain” is the conflicting ServerName declarations.

If you’ve ever delved into the intricate world of web hosting with Apache, you might have encountered the puzzling issue of conflicting ServerName declarations. Conflicts can arise when multiple virtual hosts claim the same ServerName. This clash can lead to unpredictable behavior and misrouting of requests leading to serious syntax issues on your server.

RECOMMENDED READING: How to configure Apache to use a custom 404 error page?

Let’s break it down more here

Scenario #1: Two Virtual host directives in the configuration

Let’s consider a scenario where two virtual hosts inadvertently share the same ServerName:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/site2
    
</VirtualHost>

In this example, both virtual hosts claim to be the authoritative source for “example.com” defined in the ServerName directive. With this setup, Apache, being a stickler for uniqueness, will be left scratching its virtual head, unsure of which configuration to prioritize.

To fix the two conflicting virtual hosts in the configuration file, we need to ensure that each virtual host has a unique ServerName declaration to avoid conflicts as seen below:

<VirtualHost *:80>
    ServerName example1.com
    DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:80>
    ServerName example2.com
    DocumentRoot /var/www/site2
    
</VirtualHost>

Scenario #2: The Port Predicament

ServerName conflicts are not limited to just domain names; they can also occur when different virtual hosts try to occupy the same port:

<VirtualHost *:80>
    ServerName example1.com
    DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:80>
    ServerName example2.com
    DocumentRoot /var/www/site2
    
</VirtualHost>

If virtual hosts share the same ServerName, ensure they are on different ports to maintain separation as shown below:

v

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/site1
</VirtualHost>

<VirtualHost *:8080>
    ServerName example.com
    DocumentRoot /var/www/site2
    
</VirtualHost>

Please remember to open the ports you’ve defined through the firewall on your server. You can follow this guide on how to allow traffic to and from your server using the firewall.

RECOMMENDED READING: How to install and configure UFW firewall on Ubuntu Linux

Unconfigured Hostname (optional)

The hostname is like the nickname of your server on your local network. It’s a human-readable label for your machine.

If your server’s hostname isn’t set properly or isn’t associated with a domain name, Apache gets a bit confused. It’s like asking someone, “What’s your complete address?” and they only tell you the street name without the city or country. Apache wants the full picture.

So, to fix this, you need to make sure your server has a proper hostname set, and that hostname should ideally be associated with a domain name. This way, when Apache asks, “What’s your FQDN?” your server can confidently say, “I’m www.example.com” or whatever your domain is.

Now, how likely is this to happen? Well, it depends on how your server is set up. If it’s a fresh installation and you haven’t configured the hostname or associated it with a domain, you might run into this. But don’t worry, it’s a common hiccup, and fixing it is just a matter of setting up your server’s nickname (hostname) and giving it a proper address (FQDN).

To fix this, you can set the hostname using the following command in the terminal:

sudo hostnamectl set-hostname yourhostname

Replace “yourhostname” with your desired hostname. After setting the hostname, check if the error persists upon Apache restart.

RECOMMENDED READING: How can I fix Cloudron domain redirection issues?

What is the relationship between hostname and domain name?

The domain name is crucial for people on the internet to find your server. It’s what users type into their browsers to visit your website, just like guests following your street address to attend your party.

Now, the hostname is like the specific room or service within your server. Apache can host multiple websites or services on the same machine, much like how you might have different rooms for various activities during your party. Each of these activities (or services) has its own name, and that’s the hostname in this context.

So, does the hostname really matter when you have a domain name configured on Apache?

Well, yes and no.

Yes, because it helps Apache to know which specific service or website someone is looking for. If you’re running multiple websites on your server, the hostname helps Apache direct visitors to the correct one.

And no, because if you have just one website or service on your server, you might not need to worry much about hostnames. Apache can still serve your website without explicitly specifying a hostname, and it will default to the one configured.

RECOMMENDED READING: How to Install WordPress on a VPS Server using Cloudron?

.

Adjusting the /etc/hosts File (Optional)

Editing the hosts file is an optional step, and it serves the purpose of allowing you to test your multiple websites locally before they are publicly accessible.

The /etc/hosts file maps IP addresses to hostnames. Sometimes, an incorrect entry in this file can cause Apache to misinterpret the server’s FQDN. Open the file using a text editor:

sudo nano /etc/hosts

Ensure that the first line contains your server’s IP address followed by its hostname and domain name:

your_server_ip yourhostname.yourdomain.com yourhostname

You can set up multiple hosts in the file as seen below:

127.0.0.1    example1.local
127.0.0.1    example2.local

Save the file and restart Apache to see if the error disappears.

After defining all your hosts in the hosts file, you also need to create a virtual host file for each host and define the appropriate directives as seen in the example below:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example1.local
    DocumentRoot "C:/path/to/website1"
    <Directory "C:/path/to/website1">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

It’s important to note that the individual virtual host files must have the .conf extension and should be created in the following Apache directory path:

/etc/apache2/sites-available/

Check DNS Configuration (Recommended)

If your server relies on DNS for hostname resolution, ensure that your DNS settings are correct. If you are using a domain name, verify that it is correctly configured with your DNS provider.

Creating a DNS file involves configuring domain name system (DNS) records for your domain. DNS records help direct traffic to the correct server and manage various aspects of domain functionality. Below is an example DNS file for the domain ugacomp.com with the server IP address 185.45.21.35. Note that this example includes common DNS records; you may need to adjust based on your specific needs.

Record TypeNameValue
NS@ns1.nameserver.com.
NS@ns2.nameserver.com.
A@185.45.21.35
CNAMEwwwugacomp.com.
MX@mail.ugacomp.com.

This table represents a basic set of DNS records; you may need to add or modify records based on your specific requirements, such as TXT records for SPF, DKIM, or other services.

RECOMMENDED READING: How to Point a Domain Name from Namecheap to Contabo VPS

Conclusion

The Apache server error “Could not reliably determine the server’s fully qualified domain name” might seem perplexing, but with the right understanding and troubleshooting steps in this guide, it could be resolved effectively. Following steps like configuring the hostname, modifying Apache settings, checking the /etc/hosts file, verifying DNS configuration, or ensuring proper reverse DNS lookup, you can try to fix this error and have your Apache server running smoothly. Remember, each server setup might be unique, so explore these solutions and adapt them to your specific environment for the best results.

More Apache-related articles to explore

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.
 

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.