ubuntu 16.04I have 2 node applications, app-1 and app-2, with usernames matching their application names, listening locally (on ports 8001 and 8002, respectively) on the same instance. When app-1 makes a request to app-2 I can find the remoteHost of the socket handling the request from app-2. Then when I try to look up this remoteHost via netstat and retrieve some user/process information, I find that the user associated with the socket is uid: 0 or root. My expectation is that the user associated with this connection would be app-1, since that is the application where the request is being generated. So part 1 of my question is: why is the user root and not app-1?Part 2: My goal is to get the user id of the remote process based solely on the information in remoteHost (e.g. 127.0.0.1:53900). Seems to me like the operating system should know exactly what process/user-id is using that host/port combination. So, assuming netstat will not work, for the reasons mentioned in the previous paragraph, what other system calls or utilities could I look at to get this information?
netstat (/proc/net): why is user associated with socket root? how to get user-id of 'remote' process?
networking;users;proc;socket;netstat