One Server, Multiple Websites Showing the Wrong Site: Check DNS or Nginx First?

One Server, Multiple Websites Showing the Wrong Site: Check DNS or Nginx First?

Check DNS first to confirm the domain reaches the expected address; then check Nginx’s port-specific server_name, default server, and HTTPS certificate selection. If the request is reaching Nginx but landing on its default site, adding another IP is usually not the first fix.

This guide is for website owners and technical staff managing several business, content, or export sites on one server. It helps you trace a wrong-site response from the hostname lookup to the web server, without assuming the browser’s page alone reveals the fault.

The request path: DNS, connection, and site selection

A browser does not ask DNS which website to show. DNS resolves a hostname to an address; the client connects to that address, and Nginx uses the request details to select a configured site. Those are separate stages, so a correct DNS answer does not prove that Nginx is serving the correct virtual host.

For a typical web request, check the chain in this order:

  1. The requested hostname is the one you expect, including whether it is the root name or a www alias.
  2. DNS returns the address you intended.
  3. The client connects to the server listening at that address.
  4. Nginx receives the request on the relevant port and matches its hostname against the configured server names.
  5. For HTTPS, the TLS handshake selects a certificate before Nginx processes the HTTP request.

NGINX documents that it uses the request’s Host header to select a server configuration and that unmatched requests are handled by the default server for the listening port. See NGINX’s request-processing explanation. This is why a domain can resolve correctly yet display another site: the request reached the server, but no intended host configuration caught it.

What you observe Likely stage to inspect First useful check
Browser reports that the name cannot be resolved DNS lookup Compare the resolver’s answer with the intended address
Domain opens an old or unrelated site DNS, cached answer, or Nginx default server Check the resolved address, then test the hostname against the intended server
HTTP shows the right site but HTTPS does not Separate port or TLS configuration Compare the port-specific server blocks and certificate selection
Root domain works but www does not Alias record or server_name coverage Test each hostname independently

Milestone 1: Confirm the hostname and DNS answer

Start with the exact name in the address bar. example.com and www.example.com are separate hostnames for troubleshooting purposes. One may have a correct A record while the other points elsewhere, has a stale record, or is missing the intended alias.

Query the name using the tools available on your system. For example:

dig +short example.com A
dig +short www.example.com A
dig +short www.example.com CNAME

Compare each result with the server address you expect to receive the request. An A record maps a name to an IPv4 address; a CNAME makes one name an alias of another. The DNS record and caching model are described in RFC 1035. Recursive resolvers can also retain answers according to caching rules, so a change made at the authoritative DNS service may not appear immediately in every local lookup. For operational guidance on recursive DNS, see RFC 9199.

If the local result is unexpected, compare it with a query to the authoritative nameserver or another resolver you trust. Do not make a server-side change until you know whether the client is reaching the intended address. If different resolvers return different answers, record which resolver you queried and when; that distinction helps separate DNS propagation or caching from an Nginx routing issue.

The key distinction is simple: if the hostname resolves to the wrong address, fix the DNS records first. If it resolves to the intended address, move on to the web server. A browser page that looks wrong is not enough evidence to decide which stage failed.

Milestone 2: Check Nginx host matching and the default server

Once DNS points to the intended address, check the Nginx configuration for the exact hostname and port involved. The listen directive determines which address and port a server block handles. The server_name directive lists names that Nginx can match for that server. Check both values in the configuration that is actually loaded, not only in a file you recently edited.

Look for common mismatches:

NGINX explains how server names are matched. When no name matches a request, the default server for that listening socket handles it. The default server is determined by the listen configuration, not by whichever site name looks like a catch-all. In particular, _ is not a special wildcard by itself; it is simply a name that is unlikely to match a real hostname.

That default behavior can make a missing hostname look like a DNS failure. The request may be reaching the correct machine, but Nginx has no matching site block and falls back to a default site. A safer setup gives unknown hostnames a deliberate response rather than exposing the content of a production site. You can configure a default server for each relevant listening port and decide whether it should reject or close unmatched requests. Test that behavior carefully before applying it to live traffic.

Milestone 3: Separate HTTP routing from HTTPS certificate selection

HTTP and HTTPS need separate checks. Nginx commonly serves them through separate listening configurations, so a correct site on HTTP does not prove that HTTPS uses the same hostname mapping or certificate.

For HTTPS, the client begins a TLS handshake before sending the ordinary HTTP request. Server Name Indication (SNI) can tell the server which hostname the client intends to reach during that handshake. Nginx can use that information when selecting a certificate. After the TLS connection is established, Nginx still processes the HTTP request and matches the Host header to a server configuration. These are related but distinct decisions.

Use this sequence when a browser displays a certificate for another site:

  1. Confirm that DNS sends the hostname to the intended server address.
  2. Check which certificate the server presents for that hostname during TLS.
  3. Check that the HTTPS server block listens on the expected address and port.
  4. Verify that its server_name includes the exact hostname.
  5. Check redirects between HTTP and HTTPS separately, so a redirect does not hide which configuration answered first.

The NGINX HTTPS configuration guide describes certificate configuration and SNI behavior. A client that does not send SNI may not receive the certificate intended for a particular hostname on a shared address; this is a client-compatibility boundary, not evidence that DNS is necessarily wrong. For a direct TLS check, OpenSSL’s s_client supports specifying the hostname sent as SNI.

A certificate mismatch and a wrong page are also not identical failures. The certificate may be selected incorrectly while the HTTP request later reaches the right site, or the certificate may be valid while Nginx serves the wrong content. Test the handshake and the page response as separate milestones.

FAQ: Isolating a wrong-site response

Why does a domain open another site when DNS looks correct?

A DNS answer only directs the client to an address. Nginx still has to match the request hostname against a server block for the relevant listening port. If the name is missing or the configuration did not load, the default server handles the request. Compare the resolver’s answer with the intended address, then test the hostname against that address directly.

How can you tell which Nginx site handled the request?

Send a request with the target hostname while directing it to the intended server address. Compare the response with the expected site, then inspect the active configuration and access logs. If you control the sites, a temporary unique response marker can make the destination obvious. Do not infer the selected virtual host only from a browser’s cached page or a certificate warning.

What should you check first when HTTPS shows another site’s certificate?

First verify the destination address. Then check the certificate chosen during the TLS handshake and the Nginx HTTPS server block for the requested name. SNI can affect certificate selection before the HTTP request is sent; the later Host header is used for HTTP routing. Testing those two stages separately shows whether the certificate or the page mapping is wrong.

How do you test Nginx matching after confirming DNS?

Use curl --resolve to send a request for the intended hostname to a chosen address without relying on the local DNS answer. Test the hostname on HTTP and HTTPS, and repeat for the root name and any alias. The curl --resolve option is designed for this kind of host-and-address test.

Milestone 4: Reproduce the request without relying on local DNS

Once the DNS answer is recorded, use curl --resolve to send a request to the intended address while preserving the hostname in the request. This isolates Nginx name matching from your machine’s ordinary DNS result:

curl --resolve example.com:80:SERVER_IP http://example.com/
curl --resolve example.com:443:SERVER_IP https://example.com/

Replace SERVER_IP with the address you intend to test. The hostname in the URL remains example.com; --resolve tells curl which address to use for that host and port. This makes the test useful even if your local resolver still returns an old address.

Run the same test for each hostname, such as the root domain and www alias. If the direct test reaches the expected site but a normal browser request does not, investigate DNS answers, resolver caching, or a client-side cache. If the direct test still shows the wrong site, focus on Nginx’s configuration and default-server behavior.

Next, validate and inspect the active configuration:

nginx -t
nginx -T

The first command checks configuration syntax; the second prints the configuration Nginx has loaded, including included files. Use the NGINX command-line documentation to confirm command options for your installed version. If your service uses a custom binary or configuration path, run the equivalent commands with the same options used by the running service. A successful syntax check alone does not prove that the intended server block is present or that it matches the request.

Keep the test narrow. Change one suspected cause at a time, reload only after a successful configuration check, and repeat the same request. Otherwise, a DNS change and a server-block edit made together can hide which one actually fixed the issue.

A checkable deployment and fault-isolation list

Use this list before changing DNS or adding an IP. Record the result for each hostname and protocol so you can compare it after a configuration change.

For a change record, use columns like these. A row should describe one hostname and one protocol, rather than treating a domain and all its aliases as a single test.

Hostname and protocol Expected address Expected site Certificate expectation Result
Root domain over HTTP Your intended address Intended site Not applicable Pass or investigate
Root domain over HTTPS Your intended address Intended site Certificate covers this hostname Pass or investigate
www alias over HTTP Your intended address Intended site or deliberate redirect Not applicable Pass or investigate
www alias over HTTPS Your intended address Intended site or deliberate redirect Certificate covers this hostname Pass or investigate
Unknown hostname Your intended address No production site content Depends on TLS setup Deliberate default response

The matrix is useful at launch as well as during troubleshooting. Add a domain only after its DNS record, server name, certificate, and expected redirect have all been checked. When you reload Nginx, record which configuration changed and repeat the relevant tests. This catches the common operational gap where a file is edited successfully but the active configuration or the hostname coverage is not what the operator assumed.

When another IP is—and is not—the fix

A separate IP does not automatically correct an incorrect DNS record, a missing server_name, or an unintended default server. If several sites are meant to share an address, Nginx can distinguish them by hostname when the relevant server blocks and HTTPS configuration are correct. Adding an address before tracing the request can add another DNS and configuration path without fixing the original mismatch.

A separate address may be appropriate for a requirement that genuinely depends on distinct network addresses. That is a different decision from fixing a site that falls through to Nginx’s default server. First establish which address the client reaches and which server block handles the request; only then decide whether the application has a separate IP requirement.

If you are moving several sites from shared hosting or virtual servers to a dedicated machine, include hostname routing, default-site behavior, and certificate tests in the deployment plan. A dedicated AMD physical server can give you exclusive machine resources, but it does not configure DNS or Nginx for you. You still need a clear host-to-site map, tested server blocks, and a deliberate response for unknown hostnames. Review the available AmdBit server options and pricing only after you have identified the server requirements; you can also check connection and access information when planning how your team will administer the system. If your current shared setup makes it difficult to control the active Nginx configuration, separates sites through opaque panel rules, or gives you limited access to server-level settings, a dedicated AMD machine may fit better once those operational requirements are confirmed. First use the checklist to resolve the routing fault; do not treat an extra IP as a general-purpose fix.

Frequently asked questions

Why does a domain open another site even when its DNS record looks correct?

A correct DNS answer only gets the client to an address; it does not select the website by itself. Nginx then uses the request's host name and the matching server configuration for that listening address and port. If no configured name matches, the port's default server handles the request. Check the address returned by your resolver, then test the host name directly against the intended server.

How can I tell which Nginx site handled a request?

Use a controlled request with the target domain in the URL and, if needed, curl's --resolve option to send it to a chosen server address without relying on local DNS. Compare the response with the expected site, inspect the active Nginx configuration, and check access logs for the request host and selected log fields. A unique temporary response marker can help distinguish sites during testing.

What should I check first when HTTPS shows a certificate for another website?

Check whether the client reached the intended server address, then inspect the certificate presented during the TLS handshake. HTTPS certificate selection can depend on SNI, which the client sends before the HTTP request is available. After the handshake, Nginx still needs to match the HTTP host to the intended server block. Test certificate selection and HTTP routing separately.

How do I test Nginx domain matching after confirming DNS?

Use curl --resolve with the domain, destination port, and intended server address. This keeps the domain in the request while bypassing the machine's ordinary DNS answer for that test. Repeat for HTTP and HTTPS and for each hostname, such as the root domain and its www alias. Then run Nginx's configuration test and inspect the loaded configuration.

Put Your Websites on a Server You Control

Run your sites on an AMD EPYC 7543P dedicated server with 32 cores and 64 threads reserved for you.