If I have the following netstat output:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0         ESTABLISHED 2129/mysqld
tcp        0      0         TIME_WAIT   -

If both ends of the socket are on the local machine, can the server and the client appear in either column?

1 Answer 1


No, the local address is always the end of the connection that was opened by the process being described. In this case, the MySQL server process listens on port 3306, so that’s its local address in any established connection. The queues are also specific to the connection direction described.

For an established connection, you should see the symmetric connection elsewhere in netstat or ss’s output.

TIME_WAIT connections are a special case. TIME_WAIT is used to ensure a new connection doesn’t receive stray packets; only the end of the connection which initiates its termination ever reaches that state (because the other end knows that its correspondent won’t send anything more). The connection is preserved by the operating system, so it’s no longer associated with a process; the local address is the end which closed the connection.

  • Thanks. What if the socket is in the TIME_WAIT state, like in my edit? Does that mean the information about who opened the connection is lost?
    – Mihai
    Commented Mar 9, 2018 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .