In a web browser that supports having multiple tabs, such as Firefox, do different tabs that go to different website domains use a dedicated port for each domain?.

Or does the browser use a single port for managing all tabs and therefore all domains?.

  • Browsers use 2 ports when connecting to websites, 80 is for http connections, 443 is for https connections. en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers – Moab Mar 20 '16 at 20:43
  • 7
    I know the ports used to connectto the server, but I was wondering about the port numbers used to connect from the client (host computer). – yoyo_fun Mar 20 '16 at 20:49
  • 2
    I think that the term, "outgoing ports," is imprecise. Ports are bi-directional. Maybe you could say. "local ports," instead. The local ports are used as source (outgoing) ports for sending requests, and destination (incoming) ports for receiving responses. – Ron Maupin Mar 20 '16 at 20:53
  • 6
    Ports are assigned by the OS and each new connection is assigned a new local port to make it distinct from all other open connections. – Ex Umbris Mar 21 '16 at 1:51
  • 1
    @ExUmbris: That may be a sensible and simple strategy, but TCP connections are identified by the quad { local IP, local port, remote IP, remote port}. Local port isn't necessary for uniqueness, which is a good thing: the webserver cannot use its local port at all for uniqueness. And from the webserver's perspective, remote IP isn't unique either as multiple users may be located behind a single gateway/proxy. – MSalters Mar 21 '16 at 14:57

Do browsers use different ports to connect to different websites?

Yes, they do.

Here is an example, showing my current Firefox connections (I have 9 open tabs) on Windows 7:

enter image description here


  • You can see that the local ports are all different.

  • The remote ports are usually 80 (HTTP), 443 (HTTPS) or 8080 (HTTP Alternate).

  • The full process of rendering a web page is described below. See in particular steps 5, 6, 13 and 15 (which are in bold):

    • In general rendering a single web page uses multiple connections, not all of which will be to the same remote address.

    • This is because web pages often include resources hosted elsewhere (javascript files, etc).

  • Multiple connections to the same website (eg stackoverflow.com) also have different local ports (because they are separate connections in different tabs rendering different pages).

Rendering a web page – step by step


  • Steps 5, 6, 13 and 15 (which are in bold) are directly relevant to the question.


  14. A DOM tree is built out of the broken HTML
  19. You see the page on the screen
  20. You get annoyed the whole process was too slow.

Source Rendering a web page – step by step


Each connection to a website uses a different socket with default destination TCP port 80 for plain HTTP and 443 for HTTPS. For the socket to be unique, the combination of the source IP address, source TCP port, destination IP address and destination TCP port must be different.

If you have multiple connections to the same website (assuming the website uses only 1 IP address) from the same computer, a different source TCP port must be used. This way, each connection is unique.

However, it should be noted that as of HTTP 1.1, all connections are persistent for a given period of time (unless declared otherwise). This means that the same connection can be reused by your browser if multiple resources from the same website are requested (e.g. css/js files). This also applies if you have multiple instances of the same website in your browser.

If you are on Windows, the netstat -no -p TCP command will show you all active TCP sockets and their corresponding process ID, including those of your browser:

enter image description here

If you are on Unix/Linux (Debian in this case), you can use the netstat -ntp or ss -t command:

enter image description here

  • 3
    Note that netstat will also show non-browser connections, for example email connections for an email client, news connections for a news reader. These connections will be on different remote ports. – DavidPostill Mar 20 '16 at 20:55
  • Unless I'm missing something, it seems like you are making the assumption that the asker is using Windows, although he hasn't mentioned an operating system. It's also good to list what OS you are referring to whenever providing console commands. – user45623 Mar 21 '16 at 6:50
  • 8
    @user45623: Although the screenshot is a Windows screenshot, netstat -n should work in most operating systems, including Linux and Mac OS. – Heinzi Mar 21 '16 at 7:29
  • 1
    On Windows (maybe other OSs too) you can use netstat -n -o to see which process created which connection. Or you can run SysInternal's tcpview to see the list in a GUI, with process names and icons and all. – Jonathan Mar 21 '16 at 8:55
  • Now the question is, do web browsers reuse connections from different tabs if they lead to the same server? – John Dvorak Mar 21 '16 at 16:48

As regards tabs to different websites, there is nothing in TCP that requires the local port to be different, as long as the tuple {local IP, local port, target IP, target port} is unique. For tabs to the same website, the situation is much more complex.

The browser, like any other piece of client software, uses a different local port per outgoing connection to the same target. In general it will form multiple connections to any given website, to fetch embedded resources such as images, CSS, JavaScript, etc. It will also pool those connections for possible reuse.

It isn't possible to say whether different tabs to the same website, will use distinct connections, because (a) there usually isn't a single connection per tab anyway, and (b) depending on the timing and authentication, connections may be reused between tabs; and as it isn't possible to identity the connections it therefore isn't possible to identify the local ports either.

  • Thanks. What does "pooling" a connection mean? – yoyo_fun Mar 20 '16 at 21:56
  • Instead of closing it, return it to a pool, and only closing it if it stays there idle for some timeout interval; and looking in the pool first before creating a new connection to that target. This is how HTTP keep-alive is implemented. – user207421 Mar 20 '16 at 22:00
  • So a pool is a data structure in the memory that stores opened and not yet closed connections? – yoyo_fun Mar 20 '16 at 22:04
  • That's correct, typically a map keyed by target IP:port. – user207421 Mar 20 '16 at 22:06
  • 1
    @EJP: Note that for HTTPS, it is not secure to key the map by target IP and port; you also need to distinguish between connections to different hostnames even though they happen to resolve to the same IP and port. Arguably a browser also should keep connections for different tabs separate if at least one tab is in incognito mode. – Henning Makholm Mar 20 '16 at 22:24

Yes. No. Maybe. It depends.

First, a browser may use any of these strategies for connections:

  1. Single connection (unlikely for any browser more recent than 1995)
  2. One connection per tab (basically same as #1, just very slightly better)
  3. One connection per resource (naive, but doesn't work so bad)
  4. Pool of connections with keep-alive, re-using connections
  5. Something different (read as: weird stuff)

You don't have a way of knowing which strategy a browser will use, although using a pool of connections (and re-using connections) is a reasonable assumption.

Second, the way TCP works, you have a source port, and a destination port for every connection. The pair of source and destination address/port defines the connection.
You always[1] use a well-known port (such as 80 or 443) to connect to the server (to which it listens on its advertized address), but the other port is randomly chosen. Thus, depending on from which side you look at a connection, it either has one or many possible ports.

Thus, the same tab may (and usually will) use several different ports on its end, but in principle different tabs might (if connections are pooled and different resources in different tabs are loaded from the same server) use the same port.

Since the question explicitly mentions outgoing, in the "normal" case, the port numbers would be the same regardless which tab they're in, or one of two possible ports (80 and 443). Although of course it is possible to explicitly ask for a different port (like 8080) in an URL. That's kind of rare, though.

[1] Well, not always... but let's not complicate it too much.

  • One other factor... the client-side port is typically chosen by the OS, not the browser; and the client-side port that the server sees might be different than what the browser sees, if the connection goes through a NAT device. Most OSes allocate either linearly or randomly within a (configurable) ephemeral port range, but a browser could request the same source-port across multiple connections to different servers. (And the OP is asking about client ports, not server ports.) – david Mar 22 '16 at 17:24
  • @david: It's hard to tell which one is right (or what to answer) since the Q is a tidbit ambiguous, hence my somewhat lengthy cover-all excursion. The OP is asking about the outgoing port on the client. "Client" suggests that we're talking about the source port (in TCP terms) which is the one that is freely or randomly chosen (by the implementation), but "outgoing" suggests it's really the destination port we are talking about. Which is much better described as "port on server" in layman words. Your comment on NAT is correct as seen from the server, but doesn't affect the client. – Damon Mar 23 '16 at 11:19

Your Answer

