The only way to get rid of ephemeral TCP ports is if you are a client and you have opened almost 64k outbound connections and have not closed them in the last two minutes.
This sometimes happens in test scripts, but this is not a real case, so it is not of particular interest.
The symptom of this is a communication error while connecting. If you do not receive communication errors, you do not have this problem.
source share