October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Fix Apache Default Vhost Overriding Your Custom Virtual Hosts

Apache serves the first virtual host when no configured name matches. Use apachectl -S, correct ServerName and ServerAlias, enable the site, and test each hostname on the right port.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If Apache keeps serving its default page instead of your site, the default virtual host is usually not overriding a valid match. Apache is failing to match the request’s address, port, or hostname to your custom block, then serving the first virtual host configured for that address and port. On Ubuntu and Debian, that fallback is often 000-default.conf.

Fix the problem by inspecting Apache’s parsed map, giving every custom block an explicit ServerName, adding the required ServerAlias values, enabling the site, and testing with the exact hostname. Treat HTTP on port 80 and HTTPS on port 443 as separate virtual-host groups.

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 looks more specific, and it does not normally let the stock default site outrank a correctly matching custom site. Selection happens in two stages.

1. Apache narrows the request to an address and port

First, Apache identifies the local address and port on which the request arrived. A block such as <VirtualHost *:80> belongs to the port-80 group, while <VirtualHost *:443> belongs to the port-443 group. A custom block in the wrong group cannot answer the request.

#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.

2. Apache compares the Host name

Within that address-and-port group, Apache compares the request’s Host header 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 block is the fallback, not proof that it is overriding a successful match. On Ubuntu and Debian, enabled-site links in /etc/apache2/sites-enabled commonly place 000-default.conf first, so it becomes the fallback for unmatched requests.

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

This explains several apparently different symptoms:

  • A domain shows the default page because its name is absent from ServerName and ServerAlias.
  • A request sent to an IP address falls back because it may not carry the domain name your custom block expects.
  • HTTP works but HTTPS shows the default site because only the *:80 group was configured.
  • A carefully edited file has no effect because it remains in sites-available and is not enabled.

Start with Apache’s actual virtual-host map

Do not infer the active order from filenames or from the file you most recently edited. Ask Apache to print the configuration it parsed:

sudo apachectl -S

The output identifies each address-and-port group, the first virtual host in that group, the names Apache associates with each block, and the file path from which the block was loaded.

What to inspect in the output

  • Address and port: Confirm that the request is reaching a group such as *:80 or *:443 and that your custom block is in that same group.
  • First listed block: This is the fallback when no configured name matches. If it is 000-default.conf, that is expected on many Ubuntu and Debian installations.
  • Server names: Check that the exact bare domain, www name, or other hostname appears under the intended block.
  • Duplicate names: The same ServerName or ServerAlias in multiple blocks can make the earlier definition win and leave the later site unreachable by name.
  • Unexpected file paths: If Apache reports a different file than the one you edited, you may be changing an inactive copy.

Run this command again after every configuration change. A before-and-after comparison is more reliable than assuming that an enable or reload succeeded.

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.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Build a custom virtual host that can match

Open the intended file under /etc/apache2/sites-available/. The filename can be different, but the matching directives must describe the request you will send.

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

Set an explicit ServerName

Give every intended virtual host its own ServerName. Do not rely on a machine-wide hostname, a guessed name, or an inherited value. The value must match the hostname a browser sends, apart from normal DNS resolution.

Add every required ServerAlias

Use ServerAlias for additional names that should reach the same site. A block containing only example.com does not automatically match www.example.com. Add each required alias explicitly, and test each one individually.

Keep the address and port aligned

A *:80 block handles HTTP traffic arriving on port 80. It cannot handle a request arriving on port 443. If your application is served over TLS, create or correct a separate *:443 block with the same relevant names and the directives required for that HTTPS setup.

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

Use the correct document root

DocumentRoot controls which files Apache serves after it has selected the block. It does not participate in hostname matching. A correct document root cannot repair a missing ServerName, wrong port, or disabled file, so solve matching first and then verify the path and application-specific permissions.

Enable the file and apply the change on Ubuntu or Debian

Ubuntu and Debian separate available site files from enabled site links. Apache normally loads the enabled set, not every file present in /etc/apache2/sites-available/.

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. Enable the custom site:
    sudo a2ensite example.conf

    Replace example.conf with the actual filename in sites-available.

  2. Reload Apache:
    sudo systemctl reload apache2

    A reload applies the changed configuration without requiring a full machine reboot.

  3. Inspect the parsed map again:
    sudo apachectl -S

    Confirm that the custom file now appears in the expected address-and-port group with the expected names.

If the site file is not enabled, editing it can appear to do nothing because Apache is still using the previously enabled configuration. Conversely, if an old file containing the same name remains enabled, Apache may continue selecting that earlier definition.

Decide whether to disable the stock default site

The default site is useful as an intentional catch-all: it gives unmatched requests a predictable response instead of exposing an arbitrary application. Do not disable it solely because it appears first if unmatched traffic should remain controlled.

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

If it is not needed and you want unmatched HTTP requests to stop landing on the stock page, disable it:

sudo a2dissite 000-default
sudo systemctl reload apache2

The custom site still needs a matching name after this change. Removing the fallback does not make an incorrectly named request match another block; it only removes the stock destination for requests that match nothing. After disabling it, run sudo apachectl -S and verify that the intended first block is now deliberate.

When keeping a default catch-all is safer

  • You want unknown hostnames to receive a neutral page rather than an application.
  • You use the first block as a controlled response for direct-IP requests.
  • You are migrating domains and need unmatched traffic to remain visible while DNS changes propagate.

When disabling it is reasonable

  • The server hosts only your named sites and the stock page reveals an unwanted default.
  • You have deliberately created another catch-all block with the response you want.
  • You have confirmed every production hostname is covered in the correct address-and-port group.

Test with the hostname Apache must match

A browser request to an IP address is not equivalent to a request to your domain. Name-based virtual hosting depends on the hostname in the request’s Host header. If you browse to http://203.0.113.10, Apache may have no reason to select the block for example.com, so it uses the first block for that port.

Test the bare name

Open the exact name in a browser, such as http://example.com, after DNS points it at the server. The name must be listed as ServerName or ServerAlias in the matching block.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

Test each alias

Open http://www.example.com separately if it is intended to work. A successful test of the bare domain does not prove that the www alias is configured.

Separate DNS from Apache matching

DNS determines which server receives the request; Apache then uses the hostname in that request to choose a virtual host. If DNS sends the domain to another server, local Apache changes cannot fix the result. If DNS reaches this server but the name is absent from the configured block, Apache falls back locally.

Check HTTPS independently

Repeat the tests with https://. Inspect the *:443 entries from apachectl -S, not only the *:80 entries. Correct HTTP configuration does not automatically create a matching HTTPS virtual host.

Use the symptom to choose the right repair

Symptom Likely cause What to verify
Default page appears for the domain The hostname does not match any ServerName or ServerAlias Compare the browser’s exact name with the names shown by apachectl -S
Domain works only when using a special URL or IP The IP request lacks the domain name needed for a name-based match Test the real hostname and confirm DNS points to this server
Editing a file changes nothing The file is not enabled, or another copy is active Check the file path in apachectl -S and run a2ensite
HTTP is correct but HTTPS shows the default No matching *:443 block, or the HTTPS names are incomplete Inspect the port-443 group and configure its names separately
Two domains open the same site Duplicate names or an overly broad alias sends both requests to one block Find repeated ServerName/ServerAlias entries and narrow them
Only an unknown hostname shows the default The intended site is matching correctly; the default is serving as fallback Decide whether that catch-all behavior is acceptable
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why common fixes fail

Changing the filename

Renaming a configuration file does not change its ServerName, aliases, port, or enabled state. Filename order matters primarily when Apache needs a fallback or when duplicate names compete. It is not a substitute for a matching hostname.

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

Deleting 000-default.conf immediately

Removing the stock file can hide the symptom while leaving the real mismatch unresolved. First identify the request’s address, port, and hostname. Disable the default only after confirming that the intended block is enabled and matches production traffic.

Adding a ServerAlias but testing the wrong name

An alias helps only if it exactly covers the requested hostname. Check spelling, subdomains, and whether the browser is using HTTP or HTTPS. A name present in the port-80 block does not automatically belong to port 443.

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.

Editing sites-available and skipping reload

Apache continues using its current configuration until the changed file is enabled and the service is reloaded. A saved editor buffer is not an active server configuration.

Assuming a successful DNS lookup proves the vhost is correct

DNS can correctly deliver a request to the server while Apache still selects its fallback. Treat DNS routing and virtual-host selection as separate checks.

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

Assuming the first file always wins

The first block wins only when no later block has a matching name, or when duplicate names create an ordering conflict. A correctly matching ServerName or ServerAlias should select its block regardless of whether the filename sorts before or after 000-default.conf.

A complete repair workflow

Use this sequence when you need a repeatable diagnosis rather than trial and error.

  1. Record the failing URL. Note the scheme, hostname, and whether you used a domain, alias, or IP.
  2. Map the active configuration. Run sudo apachectl -S and locate the relevant address-and-port group.
  3. Identify the selected fallback. Note the first block in that group and the file path Apache reports.
  4. Open the intended file. Make sure it resides in /etc/apache2/sites-available/ and contains an explicit ServerName.
  5. Add required aliases. Include every hostname that should serve the same application.
  6. Correct the port group. Put HTTP names in the *:80 block and configure HTTPS names in the *:443 block.
  7. Enable the file. Run sudo a2ensite example.conf.
  8. Apply the configuration. Run sudo systemctl reload apache2.
  9. Map it again. Re-run sudo apachectl -S and check for duplicates, unexpected paths, and the intended names.
  10. Test every production name. Request the bare domain and each alias over the relevant scheme.
  11. Choose fallback behavior. Keep 000-default as a deliberate catch-all or disable it with sudo a2dissite 000-default, then reload again.

Configuration patterns for common setups

One site on HTTP

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

This pattern covers the bare domain and the www alias on port 80. It does not configure TLS.

Separate HTTP and HTTPS groups

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

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example
    # TLS directives required by your Apache setup go here
</VirtualHost>

The names are repeated because Apache evaluates each port group independently. The TLS directives are application and certificate dependent; the essential vhost-matching point is that the HTTPS block exists on port 443 with the same intended names.

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

Several sites on one server

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

<VirtualHost *:80>
    ServerName other.example
    ServerAlias www.other.example
    DocumentRoot /var/www/other
</VirtualHost>

Each hostname must be unique across the enabled blocks in that address-and-port group. If a request does not match either name set, Apache returns the first block as the fallback.

How to validate that the fix is real

  • Configuration view: apachectl -S lists the expected file, names, order, and ports.
  • Hostname coverage: The exact bare domain and every required alias appear in the intended block.
  • Port coverage: HTTP requests map to *:80; HTTPS requests map to *:443.
  • Activation: The site is enabled, not merely edited in sites-available.
  • Fallback decision: The first block is either intentionally retained or the stock default is disabled.
  • Request validation: Tests use hostnames, not only a direct IP address.
  • Duplicate check: No competing block declares the same ServerName or alias unintentionally.

If all of these checks pass, a default page should no longer appear for a hostname that belongs to the custom site. Any remaining default response then points to a different layer, such as DNS directing traffic elsewhere or a request using a hostname you did not configure.

Reference and further reading

For deeper coverage of name-based matching, consult the Apache HTTP Server administration book or the Apache HTTP Server documentation on virtual-host matching. The key rule remains deterministic: for a given address and port, a matching ServerName or ServerAlias selects the corresponding block; the first block is reserved for requests that match none.

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.

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

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.