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 running instance’s effective configuration with nginx -T and look for listen directives in its HTTP server blocks. On Linux, compare that configuration with live TCP listeners using ss -ltnp. To change a port safely, edit the applicable directive, run nginx -t, then reload the same Nginx instance and verify the new listener.

Check Nginx’s configured port

The HTTP listen directive specifies the address and port on which a server accepts connections. Inspect the configuration used by the running Nginx installation, rather than assuming it uses a standard file path or binary.

  1. Identify the Nginx executable and configuration path used by the running service, container, or deployment. If it uses a non-default configuration file, pass that path with -c.

  2. Run that executable with -T and review the output for listen directives. For example, if the correct executable is available as nginx, the command is nginx -T; for a custom configuration file, use nginx -T -c /path/to/nginx.conf.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Read each listen directive in context: note both the port and address, and which server block contains it. A configuration can have multiple server blocks and listeners.

Nginx documents *:80 as the default when it runs with superuser privileges and *:8000 otherwise, if no listen directive is present. These are defaults, not a reliable way to identify the port of a particular running installation; inspect its effective configuration instead.

Confirm the live listener on Linux

The configuration dump and the socket table answer different questions: nginx -T shows the configuration Nginx loads, while ss shows live socket state. On Linux, run:

ss -ltnp

The options select listening TCP sockets, display numeric addresses and ports, and request process information. In the output, check the local address and port, as well as the process identity when shown. Process details may be unavailable without sufficient permissions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Check What it tells you What to compare
nginx -T The effective Nginx configuration that the selected executable reads. listen port, address, and server block.
ss -ltnp on Linux Live listening TCP sockets and, when permissions allow, process information. Local address and port, plus the process associated with the socket.

If the two checks disagree, first confirm that you inspected the same binary, configuration path, service instance, and network namespace that are running. A configuration value alone does not prove that a listener is live.

Understand the address and server block

A port number does not tell the whole story. A listener bound to a wildcard address can accept connections on multiple local interfaces, while one bound to a specific address is limited to that address. Compare the full local address shown by ss with the address in the corresponding listen directive.

Nginx first selects candidate servers based on the connection’s IP address and port, then uses the request’s Host header to choose among those candidates. A default server belongs to an address-port pair; if none is explicitly marked, the first server configured for that pair is the default. See Nginx’s documentation on request processing and server names. When changing a listener, check that its address-port pair and any default_server setting still match the intended routing.

Change the port without applying a broken configuration

  1. Edit the relevant server block. Change its listen directive to the intended address and port. For example, a directive such as listen 8080; specifies port 8080; use the address as well if the listener should be restricted to a particular local interface.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Test the configuration. Run the same Nginx executable with -t, and include -c /path/to/nginx.conf if the running instance uses a custom configuration file. Nginx says this checks syntax and attempts to open files referenced by the configuration. If the test fails, read the error, correct the configuration, and test again; do not reload a configuration that has not passed.

  3. Reload the running instance. Use its service manager or the correct Nginx executable’s reload mechanism. Nginx documents nginx -s reload as a way to send a reload signal, but the command must target the instance you intend to control. Service managers, containers, and orchestrators may require their own reload procedure; do not assume one command or privilege level applies everywhere.

  4. Verify the result. Check ss -ltnp again on Linux and confirm that the intended address and port are listening. Then test a request through the network path your users will use.

On a successful reload, Nginx starts new worker processes and asks old workers to shut down gracefully. If it cannot apply the new configuration, it rolls back and continues with the old configuration. The documented behavior is described in Nginx’s control documentation.

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

If the port appears wrong or unreachable

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.