Background: The port is present, but not found

As a Web developer, whether it is MAC, Linux or Windows, I almost operate a scenario every day: find the PID of a Web service and see what its service port is; There’s another scenario that you’ll often do: check to see if the next port is open. In a real world scenario, you might encounter a situation like this: “I did not find the port number based on the PID information, or I did not find the port, why is the port used when booting with this port?”

The repetition

Operate a wave to start onekafkaService (port:9092)

usess -ptl|grep 9092

The result shows that no, then change the command to look at, uselsofTake a look at?

Strange, isn’t it? The service was started, but it wasn’t found

Let’s look at some other angles

The solution

Look at this. We got what we wanted

So, to really find the port we’re looking for, do the following

  • “1. UsessCommand, plus-nParameters”
  • “2. UselsofCommand, plus-PParameters”
  1. Ss -n: Do not try to resolve service names

  2. Function of lsOF -p parameter: The conversion of port numbers to port Ames for names is a function of the conversion of port numbers to port names.

The root cause

As follows:9092withXmlIpcRegSvcThe relationship between

Service Name and Transport Protocol Port Number Registry