Sobes.tech
Junior — Middle

How can you verify that Nginx is listening on the specified port?

sobes.tech AI

Answer from AI

To check if Nginx is listening on a specified port, several methods can be used:

  1. netstat or ss command
netstat -tuln | grep :80
# or
ss -tuln | grep :80

If a line with the desired port (e.g., 80) appears in the output, Nginx is listening on that port.

  1. Using curl or telnet
curl -I http://localhost:80
# or
telnet localhost 80

If the connection is established and a response is received, the port is open and listening.

  1. Checking Nginx configuration

Look at the configuration file (usually /etc/nginx/nginx.conf or in /etc/nginx/sites-enabled/) for the listen directive.

  1. Nginx logs

If Nginx is running, error logs may contain information about the ports it listens on.

By combining configuration checks and network commands, you can verify that Nginx is listening on the required port.