title: How to determine what ports X is listening on?
body: <p>My use case is that I am running nx over ssh and the local proxy connects to the remote host via tunneling. Because it's tunneled, I tell nx to connect to localhost:port. The problem is that I need to perform X authentication and if I hit the local X server by accident instead of the remote one, I get an authentication error.</p>
  
  <p>How can I determine what port the local X server is listening on so that I can avoid it when setting up my tunnel?</p>
  
  <p>My current workaround is to avoid tunneling with any local port which already has another application listening on it.</p>