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 onekafka
Service (port:9092
)
usess -ptl|grep 9092
The result shows that no, then change the command to look at, uselsof
Take 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. Use
ss
Command, plus-n
Parameters” - “2. Use
lsof
Command, plus-P
Parameters”
-
Ss -n: Do not try to resolve service names
-
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:9092
withXmlIpcRegSvc
The relationship between
Service Name and Transport Protocol Port Number Registry