October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Fix Apache Default Vhost Overriding Your Custom Virtual Hosts

Apache usually serves the default site because the request does not match your custom virtual host's address, port, ServerName, or ServerAlias. Diagnose the parsed map, enable the correct site, reload Apache, and test HTTP and HTTPS by hostname.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If Apache keeps displaying its default page instead of your site, the default virtual host is usually not overriding a valid match. Apache is receiving a request whose address, port, or Host name does not match your custom ServerName or ServerAlias, so it serves the first virtual host configured for that address and port. On Ubuntu and Debian, that fallback is often 000-default.conf.

Use sudo apachectl -S to see the parsed map, correct the matching fields, enable the intended site, reload Apache, and test with the exact hostname. The procedure below covers HTTP, HTTPS, DNS, duplicate names, and the common reasons a fix appears not to work.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Apache chooses a virtual host

Apache does not choose a site because its configuration filename sounds right. It evaluates each request in two stages:

  1. It finds the configured virtual-host group that matches the local address and port receiving the connection, such as *:80 for HTTP or *:443 for HTTPS.
  2. Within that address-and-port group, it compares the request’s Host name with each block’s ServerName and ServerAlias, in configuration order.

The first matching name wins. If no name matches, Apache serves the first listed virtual host for that address and port. That first entry is the default or fallback; it is not a higher-priority override of a correctly matching custom block.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Apache’s virtual-host documentation describes the first name-based host for an IP-and-port pair as significant because it handles requests for which no other host has a matching ServerName or ServerAlias.

This explains several apparently different symptoms:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A domain shows the stock Apache page because its name is absent, misspelled, or assigned to another block.
  • Opening the server’s IP address shows the default site because the request may not contain your domain name.
  • A file exists in sites-available but never responds because it has not been enabled.
  • HTTP works while HTTPS shows a different site because *:80 and *:443 are separate virtual-host groups.

1. Inspect Apache’s active virtual-host map first

Do not guess which file is active. Ask Apache to print the configuration it parsed:

sudo apachectl -S

This is Apache’s virtual-host debugging command. Read the output from top to bottom and record:

  • Every address-and-port group, especially *:80 and *:443.
  • The first virtual host listed in each group; that is the fallback for unmatched names.
  • The file path Apache reports for your intended ServerName and aliases.
  • Warnings about duplicate ServerName or ServerAlias values.
  • Unexpected names or a default file appearing before the site you intended to use.

If your custom hostname is not shown at all, the file is either not enabled, contains a syntax problem that prevented loading, or does not define the name you are testing. If it appears under *:80 but you are visiting an HTTPS URL, inspect the *:443 group instead.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

2. Define an unambiguous custom virtual host

Use an explicit ServerName

Every intended virtual host should state the canonical hostname explicitly. Put alternate names in ServerAlias. A minimal HTTP block looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example
</VirtualHost>

Replace the domain and document-root path with the values for your application. The fields that determine whether this block can match are the address-and-port in the opening tag, ServerName, and ServerAlias. Application-specific directives, permissions, logs, and rewrite rules belong in the same file as required by that application, but they do not substitute for a matching name.

List every name users will actually request

example.com and www.example.com are different hostnames. If both should reach the same site, include both exactly as users enter them. An alias with a typo, an omitted subdomain, or a name assigned to another virtual host will not match the request you think it matches.

Match the listening port

A <VirtualHost *:80> block can answer HTTP traffic received on port 80. It cannot answer a request received on port 443. Conversely, adding an HTTPS URL in a browser does not make Apache reuse the port-80 block.

3. Enable the site on Ubuntu or Debian

Ubuntu and Debian conventionally keep site definitions in /etc/apache2/sites-available and activate them through links in /etc/apache2/sites-enabled. Editing a file in the first directory does not make it active until it is enabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  1. Create or edit the definition, for example /etc/apache2/sites-available/example.conf, and save the correct ServerName, aliases, address, port, and document root.
  2. Enable that definition:
sudo a2ensite example.conf
  1. Apply the change without stopping the service:
sudo systemctl reload apache2

Ubuntu’s Apache guidance uses a2ensite followed by a reload. A restart is also available when you specifically need one, but a reload is normally sufficient for a configuration change.

To confirm that the link exists, inspect the enabled directory and then run sudo apachectl -S again. The path shown by Apache should point to the definition you intended, not merely to a similarly named file that remains disabled.

4. Decide whether to disable 000-default.conf

On Ubuntu and Debian, enabled files are commonly ordered so that 000-default.conf is first. That makes it the fallback whenever no other virtual host matches. You can leave it enabled deliberately as a catch-all, or remove it when every request should be handled by your own sites.

Keep the default as a deliberate fallback

Keeping the first site is reasonable when you want unmatched hostnames to land on a controlled landing page. In that case, make the fallback intentional and verify that all legitimate domains are listed in their own blocks. Remember that a request with an unknown or missing host name will still use this first entry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable the stock site

If the stock page has no purpose on this server, disable it and reload Apache:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
sudo a2dissite 000-default
sudo systemctl reload apache2

The command removes the enabled-site link; it does not erase the original file from sites-available. You can re-enable it later with sudo a2ensite 000-default if the fallback is needed again.

Disabling the default site does not repair a wrong hostname or port. It only removes one fallback. If no remaining block matches the request, Apache will choose the first remaining virtual host for that address and port.

5. Test with the hostname Apache must match

Do not use an IP-only browser test as proof

When you browse to http://SERVER_IP/, the request may contain the IP address as its host rather than example.com. Unless a virtual host explicitly matches that name, Apache has no reason to select your domain block and will use the first host for the address and port. A successful response to the IP therefore does not prove that name-based routing works.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the bare domain and every alias

After reloading, request the exact names configured in ServerName and ServerAlias. Test both the bare name and each alias, because one can be correct while another still falls through to the default.

For a server that is reachable by IP but whose public DNS is not ready, send the expected host header explicitly:

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -i -H 'Host: example.com' http://SERVER_IP/

This test checks the HTTP name match while connecting to the known address. It does not replace DNS configuration for normal visitors; public DNS and the browser’s host header must eventually use a name listed in the intended virtual host.

Check DNS separately from Apache

The domain must resolve to the server that contains your virtual host. If DNS points elsewhere, Apache on this machine never receives the request and no local configuration change can affect the response. Once DNS points to the correct address, test again using the domain, not only the IP.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

6. Configure HTTPS as its own virtual-host group

TLS requests normally arrive on port 443, so an HTTP block alone is incomplete. Inspect the *:443 section of apachectl -S and ensure that the HTTPS definition contains the same intended hostname and aliases, along with the certificate and other TLS directives required by your setup.

A common failure sequence is:

  • http://example.com reaches the custom site through a correct *:80 block.
  • https://example.com reaches the default page because no matching *:443 block exists, or because another certificate host is first for that address and port.

Fix the 443 definition independently, reload Apache, and test the HTTPS hostname again. Correcting only port 80 cannot change which virtual host handles a TLS connection.

7. Diagnose the common failed fixes

Symptom or attempt Why it fails What to check
Opening the server IP shows the default page The request may not contain the domain name required for a name-based match. Test with the configured hostname or an explicit Host header.
The file is edited, but the response never changes A definition in sites-available is not active until its site is enabled. Run sudo a2ensite example.conf, reload, and verify with apachectl -S.
ServerName is missing Apache may inherit or deduce a name that does not match the request. Add an explicit ServerName and put alternate names in ServerAlias.
HTTP is fixed but HTTPS is not Port 80 and port 443 are separate address-and-port groups. Inspect and configure the *:443 virtual host separately.
Renaming a file appears to fix it Filename order controls fallback order, not whether a correctly matching name wins. Use apachectl -S to find duplicate names and confirm the actual match.
Two sites claim the same name Apache cannot use both as an unambiguous match; configuration order determines which duplicate wins. Remove the duplicate ServerName or ServerAlias and reload.
The stock page remains after disabling one file Another enabled virtual host may now be first, or the request still does not match any name. Re-run apachectl -S and inspect the first entry for that address and port.

8. Understand ordering without relying on it

Configuration order matters in two specific situations:

  • It selects the fallback when no ServerName or ServerAlias matches.
  • It resolves a duplicate-name situation, because only one entry can win when multiple blocks claim the same name for the same address and port.

Order does not make a nonmatching block beat a matching one. If your request is example.com and only your custom block lists that name, Apache should select it even if 000-default.conf appears earlier. Spending time renaming files before checking the host name, port, and enabled status often hides the real problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

9. A disciplined repair workflow

Use this sequence whenever the wrong site appears:

  1. Identify the URL being tested. Record whether it is HTTP or HTTPS, the exact hostname, and whether you are using an IP address.
  2. Print Apache’s map. Run sudo apachectl -S and locate the relevant address-and-port group.
  3. Find the fallback. Note the first listed block and the file path Apache reports for it.
  4. Find the intended block. Confirm that it is present, enabled, and in the same address-and-port group as the request.
  5. Correct the names. Add an exact ServerName; add each required alternate hostname as a ServerAlias.
  6. Enable the definition. On Ubuntu or Debian, run sudo a2ensite example.conf if it is not already enabled.
  7. Reload Apache. Use sudo systemctl reload apache2.
  8. Retest by name. Test the bare domain, every alias, and the HTTPS URL if applicable. Use a host-header curl test when DNS is not yet available.
  9. Choose the fallback policy. Keep 000-default.conf only if an intentional catch-all is useful; otherwise run sudo a2dissite 000-default and reload.
  10. Print the map again. The final apachectl -S output should show the intended names under the correct ports and no unexpected duplicates.

10. Compare the available fixes before changing production

Fix What it changes When it is appropriate Limitation
Add or correct ServerName Creates the exact name match Apache needs. The custom block exists but the requested hostname is not declared correctly. Does not help if DNS points to another server or the request uses another name.
Add ServerAlias Maps additional hostnames to the same block. Both the bare domain and names such as www should serve one site. Each alias must be spelled exactly as requested and must not duplicate another block.
Enable the site Places the definition in Apache’s active configuration. The file was created or edited under sites-available but is absent from the parsed map. Activation alone cannot correct a wrong name, port, or document root.
Disable 000-default Removes the stock fallback from the enabled set. The default page is unnecessary and you want unmatched requests handled by another deliberate first host. It does not create a match; another first host will still answer unmatched requests.
Add or correct the *:443 block Handles HTTPS independently from HTTP. Port 80 works but HTTPS selects the wrong site. Certificate and TLS settings must also be valid for the requested name.

11. Final verification checklist

  • sudo apachectl -S lists the custom virtual host under the port you are testing.
  • The block has an explicit ServerName.
  • Every required alternate hostname appears in ServerAlias.
  • The address and port in <VirtualHost> match the connection: typically *:80 for HTTP and *:443 for HTTPS.
  • The file is enabled on Ubuntu or Debian, not merely saved in sites-available.
  • Apache was reloaded after the change.
  • DNS sends the domain to this server.
  • You tested with the domain name, not only the server IP.
  • The first host is intentionally retained as a fallback or the stock default has been disabled.
  • No duplicate ServerName or ServerAlias entries remain for the same address and port.

When these checks agree, Apache’s behavior is deterministic: a request whose address, port, and host name match your custom block is served by that block; only an unmatched request goes to the first virtual host.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.