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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If Nginx is installed but your site will not load, first prove where the request stops: before it reaches the server, at the listening socket, during server-block selection, while reading a static file, or when connecting to an upstream application. A running Nginx process alone does not prove that your domain is using the intended configuration. Work through the checks below in order, using the configuration dump and logs as evidence before changing settings.

Start by identifying the exact failure

Different browser messages point to different layers. Record the complete URL, whether it uses HTTP or HTTPS, the HTTP status (if any), and whether the result changes when you connect directly to the server’s IP address.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
What you see What it usually proves First place to investigate
Connection refused No process is accepting the destination address and port, or a firewall is actively rejecting it. Listening sockets, listen directives, firewall and security-group rules.
Connection timeout Packets are being dropped or routed to the wrong endpoint. DNS, cloud firewall, load balancer, public IP, and network path.
Nginx welcome page or another site The request reached Nginx, but a different server block answered. Host header, server_name, default_server, and enabled configuration files.
404 Not Found The selected server handled the request but could not map the URI to content. root, try_files, rewrites, and the requested path.
502 Bad Gateway or 504 Gateway Timeout Nginx selected the proxy configuration but could not complete the upstream request. proxy_pass, upstream DNS, port, protocol, and backend process.
TLS or certificate warning The HTTPS endpoint, certificate, key, or hostname does not match what the client expects. listen 443 ssl, certificate paths, DNS, and the browser’s exact certificate error.

Do not jump straight to reinstalling Nginx. The following workflow preserves the evidence needed to distinguish these cases.

1. Validate the loaded configuration before reloading

Run a syntax and configuration test before every reload:

#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.
sudo nginx -t

A successful result means Nginx can parse the configuration it is about to use; it does not prove that the right server block, document root, certificate, or upstream is correct. If the command names an include file, directive, permission problem, or line number, fix that exact item first. Do not reload a configuration that fails this test.

Next, identify which build and paths are in use:

nginx -V

The output can show the compiled --conf-path, --error-log-path, and whether Nginx was built with --with-debug. Packages, source builds, containers, and custom service units can use different locations, so do not assume that a distribution’s conventional path is the one your process reads. A common Linux error log is /var/log/nginx/error.log, but verify the path in your build and in the active configuration.

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

To see the complete configuration after all include files have been expanded, use:

sudo nginx -T

Save or page through this output. It is the authoritative view for finding duplicate listeners, an unexpected default server, a misspelled hostname, or a site file that is not included at all.

2. Confirm that the service is running and listening where you expect

Check the service manager used by your operating system. On a systemd host, for example:

sudo systemctl status nginx
sudo systemctl is-active nginx

An active service still might be listening only on a local address, only on IPv6, or on a nonstandard port. Inspect sockets with the platform’s socket utility:

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

Look for Nginx (or its worker processes) on the address and port your browser is contacting, normally TCP 80 for HTTP and TCP 443 for HTTPS. Compare the observed socket with every relevant listen directive in nginx -T. A listener on 127.0.0.1:80 cannot accept a request arriving on the server’s public interface. A listener on IPv6 may not answer an IPv4 connection if the operating-system and socket settings do not provide dual-stack behavior.

The listen directive selects the local address and port (or a Unix-domain socket) for a server block. Omitted values have defaults that depend on context, version, and privileges, so make the address and port explicit when troubleshooting. If another process already owns the port, Nginx normally reports the bind error in the service log and fails to start or reload.

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.

3. Prove which server block receives the request

Nginx first groups requests by the address and port selected by listen, then compares the HTTP Host header with server_name. If no name matches, the request goes to the default server for that address and port. That is why an installed site can show the generic welcome page even though Nginx is healthy.

Inspect all enabled server blocks

In the output of sudo nginx -T, check:

  • The intended hostname appears exactly in server_name, including whether you need both the apex name and its www variant.
  • The site file is actually included; a file sitting in a directory is irrelevant if no active include directive loads it.
  • No unintended block uses default_server on the same address and port.
  • HTTP and HTTPS have separate, deliberate listeners and server names.
  • There are no duplicate or conflicting listen declarations that make another block win.

Test name matching locally

From the Nginx host, send a request to the loopback address while supplying the intended Host header:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -I -H 'Host: example.com' http://127.0.0.1/

Replace the hostname with the one in your configuration. Then test the public address directly:

curl -I -H 'Host: example.com' http://203.0.113.10/

Use the server’s real public IP in place of the documentation address above. If the loopback test returns your site but the public test does not, investigate DNS, firewalls, load balancers, and routing rather than editing the server block. If both return the welcome page, the problem is selection or loading of the configuration. The Host header is essential: testing only http://127.0.0.1/ asks Nginx to choose a default site.

4. Fix static-file sites

For a site served directly from disk, the selected server block must map the URI to the intended directory. Inspect its root and any URI-handling directives:

server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example;
    index index.html;
}

Confirm that the requested file really exists at the path implied by the URI. For / and the configuration above, Nginx commonly looks for /var/www/example/index.html. Check each directory in the path:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ls -ld /var/www /var/www/example
sudo ls -l /var/www/example/index.html

The Nginx worker user needs execute permission on every parent directory and read permission on files it serves. Ownership and mode bits that work for your login account may still deny the service account. Correct permissions according to your distribution’s security policy rather than making the entire tree world-writable.

Check URI rules

A try_files directive, rewrite, or nested location can change the path Nginx evaluates. Read the effective order in nginx -T, then request the exact failing URI with verbose curl output:

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.
curl -v http://127.0.0.1/app/page

Use the access log to confirm the URI Nginx received. A 404 for one path does not establish that the root directory is wrong; it may be a typo in the URL, a missing generated file, or a rewrite that points elsewhere.

5. Fix reverse-proxy sites and upstream errors

A reverse proxy introduces a second reachability boundary. Nginx may be listening correctly and selecting the right server block while the application behind it is stopped, bound to a different interface, or speaking a different protocol.

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.

Inspect the proxy_pass inside the matching location:

location / {
    proxy_pass http://127.0.0.1:3000;
}

The target must have the correct protocol, hostname or IP, and port. Test it from the Nginx host, not from your workstation:

curl -v http://127.0.0.1:3000/

Replace the address with the actual upstream. If the upstream uses HTTPS, test HTTPS and verify that the backend expects the path and headers Nginx sends. For a hostname target, confirm that the Nginx host can resolve it and that the resolved address is reachable. A backend listening only on another container, private interface, or Unix socket will not answer a loopback TCP target.

Check the backend’s own service status and logs, then compare its listening socket with the proxy_pass destination. Do not “fix” a 502 by changing the public listener: the error normally means the proxy-to-upstream leg failed. A 504 generally indicates that the connection or response exceeded a timeout; the error log identifies whether the connection, header, or response phase timed out.

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

6. Read access and error logs during one controlled request

Logging is the quickest way to replace guesses with evidence. Find the active access_log and error_log directives in the expanded configuration. If none is specified, consult the paths reported by nginx -V and your package’s service configuration.

Tail the relevant files in one terminal:

sudo tail -F /var/log/nginx/access.log /var/log/nginx/error.log

In a second terminal, make exactly one request:

curl -v -H 'Host: example.com' http://127.0.0.1/

Match the timestamp, client address, Host, URI, status, response size, and upstream fields. The access log tells you whether Nginx received the request and what it returned. The error log explains configuration failures, permission denials, missing files, upstream connection errors, and timeout details. A request that never appears in the access log did not reach that Nginx instance or listener.

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

Keep the request controlled while changing one variable at a time: first loopback versus public address, then hostname, protocol, and URI. This prevents unrelated browser redirects or cached errors from obscuring the result.

7. Interpret the common symptoms without skipping layers

Symptom Evidence to collect Targeted corrective action
Refused connection ss -ltnp, service status, and firewall rules. Start or repair Nginx, bind the intended address and port, or allow the port through the host and provider firewalls.
Timeout DNS result, public IP, routing, security-group rules, and load-balancer health. Point DNS at the active endpoint and allow traffic; if a proxy is involved, test each hop separately.
Welcome page or another virtual host nginx -T, Host-header curl test, and enabled includes. Load the intended site file, correct server_name and listen, and remove or deliberately designate the default block.
404 Selected block, exact URI in access log, root, try_files, and rewrite rules. Correct the document root or application route, create the missing file, or repair the rewrite.
502/504 Error-log upstream message, backend status, DNS resolution, and a direct curl from the Nginx host. Start the backend, correct protocol/host/port, permit the connection, or address the backend timeout.
HTTPS failure Browser certificate text, the selected 443 block, certificate/key readability, and DNS. Use the intended listen 443 ssl block, readable matching certificate and key, and a DNS record that reaches that endpoint.

8. Troubleshoot HTTPS separately

HTTP and HTTPS can select different server blocks. Confirm that the public request reaches the intended listen 443 ssl block and that its server_name matches the hostname in the certificate. Verify the configured certificate and private-key paths, then check that the Nginx worker can read them without loosening permissions unnecessarily.

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.

DNS must point the hostname to the endpoint serving the certificate. If DNS points to an upstream load balancer or another server, changing a local Nginx certificate will not affect the browser. Capture the exact browser error and correlate its time with the Nginx error log; “certificate expired,” “hostname mismatch,” an unreadable key, and a failed TLS handshake require different fixes.

9. Escalate to debug logging only when normal logs are insufficient

Debug logging is verbose and should be temporary. First verify support:

nginx -V 2>&1 | grep -- --with-debug

If the build includes --with-debug, set an error_log directive to the debug level in the narrowest useful context, such as the affected server block, then validate and reload:

error_log /var/log/nginx/example-debug.log debug;
sudo nginx -t && sudo systemctl reload nginx

Debug can be enabled globally or for one server block. A more specific error_log without the debug level overrides a broader debug setting for that context, so inspect nested configurations if no debug entries appear. Revert the setting after reproducing the problem because debug logs can grow quickly and may contain request details.

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

10. Apply changes safely and choose the smallest effective fix

Use this change cycle for every edit:

  1. Record the current behavior and one representative curl command.
  2. Edit only the file and directive implicated by the evidence.
  3. Run sudo nginx -t.
  4. Reload rather than restart when the test succeeds: sudo systemctl reload nginx.
  5. Repeat the same curl request and compare access and error logs.
  6. Restart only when a change requires process replacement or the service manager reports that reload cannot apply it.

When two fixes appear plausible, compare them on four axes:

Decision axis Prefer the option that
Failure location Addresses the earliest failed boundary: client/DNS, listener, server selection, static file, or upstream.
Scope and reversibility Changes one server block or one include instead of global defaults.
Required service action Needs only a validated reload rather than an unnecessary restart.
Evidence Produces a clear before-and-after change in access or error logs.

When local tests pass but the public site still fails

If a Host-header request to loopback and the server’s public IP both return the intended response, Nginx and the site configuration are probably functioning. Move outward: verify the authoritative DNS records and propagation, confirm that the address is the one assigned to this host, and check cloud security groups, network firewalls, reverse proxies, load balancers, and port forwarding. Test IPv4 and IPv6 independently if both records exist. A managed DNS or hosting provider can help only after you have established which public endpoint should receive the request and what your local logs show.

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.

Frequently asked questions

Does a successful systemctl status nginx prove my domain is configured?

No. It proves the service manager sees a running process. The process may be listening on a different address, using a different configuration file, or returning the default server because the Host header does not match.

Why does curl http://127.0.0.1 show a different site than my browser?

The loopback command normally sends a Host header for 127.0.0.1, while the browser sends your domain. Nginx uses that header after matching the listener, so test loopback with the domain explicitly supplied.

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

Should I restart Nginx after every configuration edit?

No. After nginx -t succeeds, a reload applies configuration changes while existing workers finish current requests. Reserve restarts for cases where reload is explicitly required or the service manager indicates a process-level problem.

What if the error log path I expected does not exist?

Use nginx -V to see the compiled default path, then inspect the active error_log directives in nginx -T. Packaging, containers, and custom builds commonly redirect logs elsewhere.

When is debug logging justified?

Use it after configuration, listener, server-selection, file, upstream, and normal-log checks have not isolated the failure. Confirm --with-debug support first, scope the setting narrowly, reproduce one request, and then disable it.

Frequently Asked Questions

Can DNS be the cause if Nginx is returning a page?

If you can see any Nginx response, that particular request reached an Nginx listener. DNS can still send other users, IPv4 clients, or HTTPS traffic to a different endpoint, so compare DNS answers with the address tested directly.

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

How do I know whether a 502 is caused by Nginx or my application?

Read the Nginx error-log upstream message and make a direct request to the configured upstream from the Nginx host. A failed direct connection or a stopped backend points to the application path; a successful direct response shifts attention to proxy settings, headers, or timeouts.

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.