Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a hard limit of 65536 open TCP connections per IP address on linux? I read somewhere that there was, but someone is asking for confirmation and i just can't find it.

I seem to remember it was something about the file descriptors being a 16 bit integer which limits it somehow?

Or is this hokum, and is there simply no limit other than how beefy the server is?

share|improve this question
up vote 20 down vote accepted

You may be thinking of number of ports. There are 65536 ports available in the TCP in the current versions of IPv4. This is not just a Linux limitation, its part of the protocol. Your IP address identifies your machine, and the port identifies a program on your machine.

But, the number of connections isn't limited by that. A connection consists of 5 pieces of info, in geek speak a 5-tuple. It is determined by protocol (TCP, UDP), local IP address and port, and remote IP address and port. So, take a webserver. It can service many connections on the same port (most likely 80). Your webserver can even support multiple connections to the same client machine. Say, you're connecting to from two windows. Your machine will pick an unused port for each connection. So, google's server will have to keep track of (TCP,, 80, yourmachine, someport1) and (TCP,, 80, yourmachine, someport2). At some point you'd bump into limits, but it's not a hard limit, and is very system dependent.

And yes, each socket is a file descriptor, but not all machines use shorts for the fd table. On my system, a not tuned at all system, cat /proc/sys/fs/file-max gives 323997. I'm sure I could boost it if I needed to.

So, there is a limit of 65336, but it has to do with addressing, not number of connections. Number of connections is limited, but more by system config, and how much memory it has.

share|improve this answer
So, re the 5-tuple: even though i'm limited to 65536 ports, that only limits me to 64k connections per incoming IP address, is that right? So the only limit is the file descriptors, but they're not necessarily 16 bit? So basically what you're saying is there are no limits? – Chris Mar 1 '11 at 0:52
yes. See also: section "Resource usage" – user12889 Mar 1 '11 at 2:28
@Chris: 64k connections per incoming IP address on a single local port, yes. – grawity Mar 1 '11 at 13:28
@Chris what grawity said. The 5-tuple will have up to (but never reaching) 65536 combinations with the other machine. In reality, you'll never get there because a machine can't use any old port for a connection - some are reserved for specific reasons. – Rich Homolka Mar 2 '11 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .