Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon 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 NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Which Port Is Nginx Listening On? Check and Change It Safely

Find Nginx’s configured port with nginx -T, verify live Linux listeners with ss -ltnp, and validate changes before reloading.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To find the port Nginx is configured to use, inspect the active configuration with nginx -T and look at the listen directives in the relevant server blocks. On Linux, compare that with live TCP listeners using ss -ltnp. To change a port safely, edit the right listen directive, run nginx -t, then reload the running Nginx instance.

Check the port in Nginx’s configuration

Use the same Nginx executable and configuration path that control the running server. A custom installation may use a different binary or configuration file; Nginx’s -c option selects an alternate configuration file.

As an Amazon Associate I earn from qualifying purchases.

  1. Run nginx -T with the appropriate executable and any required options, such as -c /path/to/nginx.conf.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. In the output, find the relevant server block and inspect its listen directive or directives. The directive specifies the address and port on which that server accepts connections. Nginx documents *:80 as the default when it runs with superuser privileges and *:8000 otherwise; if no listen directive is present, that documented default applies. See Nginx’s HTTP core-module documentation.

nginx -T tests and dumps the configuration Nginx loads. It answers what the configuration specifies, not necessarily which sockets are currently open.

Confirm the live listener on Linux

Run ss -ltnp on the host or in the relevant network namespace. The options select listening TCP sockets, display numeric addresses and ports, and request process information. The -p details may not be available unless you have sufficient permissions. For option definitions, see the ss(8) manual.

Read both the port and the local address. A wildcard address and a listener bound to one specific address do not have the same scope. Compare the live output with the listen directives: a mismatch can point to a different binary or configuration path, service state, permissions, or network namespace.

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

The two checks answer different questions: nginx -T shows configuration, while ss shows live socket state. A local listener alone does not prove that clients outside the host can connect. Host firewalls, cloud security groups, container port publishing, and upstream proxies can affect reachability.

Understand which server block handles a port

A port can be shared by multiple Nginx server blocks. Nginx first selects candidate servers using the connection’s IP address and port, then uses the request’s Host header among those candidates. A default server belongs to an address-and-port pair; if no block is explicitly marked default_server, the first server for that pair is the default. See how Nginx processes a request and the server names documentation.

When changing a port, check every relevant listen directive and confirm that the address, port, and default-server behavior are intentional. Changing one block does not automatically change other blocks or an upstream proxy’s configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Change the port and apply it safely

  1. Identify the running instance’s executable, configuration file, and service manager or orchestration method. Use the invocation that controls that instance rather than assuming a particular installation path or init system.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Edit the intended server block’s listen directive. For example, changing listen 80; to listen 8080; changes that block’s configured port; use the actual address and port required by your deployment.

  3. Test the edited configuration with the matching executable and options, for example nginx -t or nginx -t -c /path/to/nginx.conf. Nginx checks syntax and attempts to open files referenced by the configuration. Do not reload if the test fails; correct the reported issue and test again. See Nginx command-line parameters.

  4. After a successful test, reload the running instance through its service manager or with the correct executable’s nginx -s reload mechanism. The signal command must target the instance using the intended configuration and control setup.

  5. Run ss -ltnp again and test access from the network path clients will use. If the new listener exists locally but cannot be reached, check the deployment’s firewall, cloud networking, container publishing, and proxy configuration.

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

On a successful reload, Nginx starts new worker processes and asks old workers to shut down gracefully, allowing existing requests to finish. If Nginx cannot apply a reloaded configuration, it rolls back and continues with the old configuration. Details are in Nginx’s control documentation.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.