How to resolve a Windows or Linux system that runs out of the tcp/udp ports on a single server? I have over around 65000 tcp/udp ports being used on a single server as a result of SQL connections, user connections for users to connect to the internet, and acting also as a gateway.
I recommend to plan separation of roles (unless the gateway requires the SQL to be on the same host) - not due the fact that you're running out of ports. If the SQL is not required by the gateway and/or it's holding company data, it's quite risky to be on a gateway node.
Speaking of TCP, there are plenty of available ports. You may (while ignoring things like port sharing) only bind 216 ports per address, you may have far more active connections per address.
You can handle thousands of connections with even a single TCP port - the connection is defined due multiple parameters:
An important parameter may be half-open connections - if one of your services has some trouble, it may affect other services running on the system. You may get some more information here.
Split the server role to other server if the load is too big.
In example, in windows if you virtualize a Windows Server Standard license you can got two running instance free in virtual (1:2)
Other idea to give more physical's interface or virtual IP could help in the short term, but having such role (SQL, Gateway and user connection to the internet) is not a good idea.
In example, if a user get a malware and flood your gateway it will put down other service on the server.