Is there a way to overcome the port limit on a linux system? We have a server running that accepts incoming connection and it uses very little memory and cpu. It's rather silly that we have to build a cluster of small linux boxes just to overcome a software limit (number of points of around 60k). Any ideas?
-
1Can you give any more information about the use-case here? – jcolebrand Aug 16 '10 at 21:30
-
3Have you tried using secondary IP addresses on the same interface? – a'r Aug 16 '10 at 21:33
-
@ar: that's a viable solution since the OP is already using multiple IP addresses. Post it as an answer so it can properly get voted and/or accepted. – slebetman Aug 16 '10 at 21:58
-
possible duplicate of [Max number of socket on Linux](http://stackoverflow.com/questions/3430474/max-number-of-socket-on-linux) – cHao Aug 16 '10 at 22:13
-
It's been possible for a long time to have Linux boxes supporting well over 100,000 simultaneous inbound connections. You are hitting a configuration or resource limit - what is the actual error that makes you think you have hit a port limit? – caf Aug 17 '10 at 00:06
-
The questions is ill stated. The OP needs more than 65k connections, not more ports; because the port limit is imposed by the protocol (there are only 16 bits for specifying the port--16 bits = 64k, end of discussion). You will save your answerers considerable trouble if you ask for what you want, not how you think you should get it. – dmckee --- ex-moderator kitten Aug 17 '10 at 03:10
3 Answers
There is no limit of 60k tcp or udp sockets, you just think there is. The actual limit is much higher. There are 64k ports, but the same port may be used for more than one connection, as only the pair of addresses/ports needs to be unique.
Having said that, if you have 60k distinct clients concurrently connected, you may a have high availability requirement which means you'll need to have several machines anyway.

- 62,604
- 14
- 116
- 151
This isn't a software limit of ports, it's a networking limit.
http://en.wikipedia.org/wiki/TCP_and_UDP_port
There are only only a certain number of ports available on an IP network (65k). Your problem isn't a port limit, but perhaps how those ports are being used.

- 20,880
- 28
- 119
- 189
-
-
2Not uncommon. Most web servers do the same thing hence the HTTP Keep Alives. Without knowing the application here it's hard to give you any direction. Please tell us how you're using this. – Keith Adler Aug 16 '10 at 21:39
-
1Incoming connections all connect to the same port -- and any stack that can't handle two clients connecting from the same port number on different IPs is broken. – cHao Aug 16 '10 at 22:23
It's not Linux, it's TCP/IP design limitation - port number is a 16-bit unsigned integer, thus 64K limit. Assign multiple addresses - IP aliases - to an interface (or use multiple hardware interfaces), make different servers listen on different IPs. Each interface will give you a separate port range.

- 82,306
- 11
- 110
- 171
-
Incoming connections all connect to the same port -- and any stack that can't handle two clients connecting from the same port number on different IPs is broken. – cHao Aug 16 '10 at 22:21
-
Hmm, I'm talking about different linstening sockets on different IPs. – Nikolai Fetissov Aug 16 '10 at 23:09
-
What i mean is, any self-respecting TCP/IP stack will keep the remote clients 10.0.0.1:1234 and 10.0.0.2:1234 separate, and will allow connections from the both of them at the same time to the same port on the server. So the 64k port limit doesn't apply, even if you use a single IP -- the local and remote socket addresses should be considered 48-bit values (32 bit address + 16 bit port). – cHao Aug 17 '10 at 06:50