<p>Bitcoin client that accepts inbound connections, lets call it server, can accept a limited number of them. Assuming number of clients is greater then number of servers, if clients have no heavy restrictions on number of outbound connections, then it would overload servers and deny access to blockchain data to some clients. </p>

<p>To illustrate, imagine situation where there is only one server on the network and many bitcoin clients, if clients can reserve as many server connections as they want that would for sure prevent some clients from connecting to the server.</p>

CC BY-SA 3.0
2011-11-11T23:27:22.240Z
2011-11-11T23:27:22.240Z
Serith
<p>the constants to set numbers of connections are in src/net.h</p>

<p><code>static const int MAX_OUTBOUND_CONNECTIONS = 8;</code></p>

<p>in the repo on github:
<a href="https://github.com/bitcoin/bitcoin/blob/3bf06e9bac57b5b5a746677b75e297a7b154bdbd/src/net.h#L59" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/3bf06e9bac57b5b5a746677b75e297a7b154bdbd/src/net.h#L59</a></p>

<p>change to what you like and recompile</p>

CC BY-SA 3.0
2016-12-01T22:42:38.623Z
2016-12-01T22:42:38.623Z
Albert S
<p>This is a legacy issue.</p>

<p>When the network was first implemented, there was a severe shortage of servers that could reliably accept inbound connections. Many people started running the client behind NAT and they could not accept any inbound connections. Meanwhile, they were consuming the available inbound connection capacity of the more limited number of machines that could accept them. The client now enables uPNP traversal by default.</p>

<p>Second, there were problems with the client code that caused it not to be able to support as many connections as it should have been able to. Many nodes could not even support the default 125 connections, even though their CPU and network usage was nowhere near maxed.</p>

<p>These days, it's just kind of stuck. My 'hub mode' patches make it easily possible for clients to support 1,500 connections. But they almost never see more than 200 clients because the network capacity limitations are long gone.</p>

<p>You need a healthy number of outbound connections because a malicious adversary can consume all your inbound connection slots by repeatedly connecting to you, and staying connected, from a variety of IP addresses. The Bitcoin client actually has code to try to get IP diversity in its outbound connections to protect against some entity creating a million servers and having a high chance of getting all 8 of your outbound slots.</p>

<p>If you're paranoid, turn this up. You can still configure for 32 outbound connections if you can also add at least 64 inbound connection slots in exchange. You'll be helping the network. You can use my hub mode patches to do this.</p>

CC BY-SA 3.0
2011-11-13T02:06:56.990Z
Thanks.  So why haven't the developers increased the limit in mainline client?  One would think with each version they would make some adjustments.  Looking at the newbie section on Bitcointalk forum the slow and inconsistent performance downloading blockchain is a continual problem.  As the block chain gets no longer the 8 connection limits appear at least to me to be more and more archaic.  At least bumping it to 16 would allow higher throughput for new clients.
DeathAndTaxes
CC BY-SA 3.0
2011-11-13T02:09:04.613Z
I think the slow block sync rate is due to two issues, neither of which are related to the connection limit. One was a bug that was fixed but older clients still mess up newer ones. The other is the fact that the client validates every block, every hash, and every transaction. There are over 100,000 blocks and typical PCs can't validate more than about 15 per second.
David Schwartz
CC BY-SA 3.0
2011-11-12T01:22:47.323Z
2011-11-12T01:22:47.323Z
David Schwartz
<p>The mainline Bitcoin client limits number of outbound connections to 8 however allows up to 125 total connections.  To achieve greater than 8 connections (due to outbound limitation) requires either using uPnp or port forwarding so that the client can accept inbound connections.</p>

<p>Why is there a limit of 8 connection and only on outbound connections?  Why not allow the client to create 20 or 125 outbound connections?</p>

<protocol><bitcoin-core><network>
Why does the mainline client limit the number of outbound connections to 8?
DeathAndTaxes
# Why does the mainline client limit the number of outbound connections to 8?

(Asked by: username_0 on 2011-11-11)

The mainline Bitcoin client limits number of outbound connections to 8 however allows up to 125 total connections. To achieve greater than 8 connections (due to outbound limitation) requires either using uPnp or port forwarding so that the client can accept inbound connections.

Why is there a limit of 8 connection and only on outbound connections? Why not allow the client to create 20 or 125 outbound connections?

**Tags:** protocol, bitcoin-core, network


---

## 3 answers

### Answer by username_3 on 2011-11-12. Score: 8 | Accepted answer

This is a legacy issue.

When the network was first implemented, there was a severe shortage of servers that could reliably accept inbound connections. Many people started running the client behind NAT and they could not accept any inbound connections. Meanwhile, they were consuming the available inbound connection capacity of the more limited number of machines that could accept them. The client now enables uPNP traversal by default.

Second, there were problems with the client code that caused it not to be able to support as many connections as it should have been able to. Many nodes could not even support the default 125 connections, even though their CPU and network usage was nowhere near maxed.

These days, it's just kind of stuck. My 'hub mode' patches make it easily possible for clients to support 1,500 connections. But they almost never see more than 200 clients because the network capacity limitations are long gone.

You need a healthy number of outbound connections because a malicious adversary can consume all your inbound connection slots by repeatedly connecting to you, and staying connected, from a variety of IP addresses. The Bitcoin client actually has code to try to get IP diversity in its outbound connections to protect against some entity creating a million servers and having a high chance of getting all 8 of your outbound slots.

If you're paranoid, turn this up. You can still configure for 32 outbound connections if you can also add at least 64 inbound connection slots in exchange. You'll be helping the network. You can use my hub mode patches to do this.

> **Comments:**
> **username_0**: Thanks.  So why haven't the developers increased the limit in mainline client?  One would think with each version they would make some adjustments.  Looking at the newbie section on Bitcointalk forum the slow and inconsistent performance downloading blockchain is a continual problem.  As the block chain gets no longer the 8 connection limits appear at least to me to be more and more archaic.  At least bumping it to 16 would allow higher throughput for new clients.  
> **username_3**: I think the slow block sync rate is due to two issues, neither of which are related to the connection limit. One was a bug that was fixed but older clients still mess up newer ones. The other is the fact that the client validates every block, every hash, and every transaction. There are over 100,000 blocks and typical PCs can't validate more than about 15 per second.  

---

### Answer by username_1 on 2011-11-11. Score: 2

Bitcoin client that accepts inbound connections, lets call it server, can accept a limited number of them. Assuming number of clients is greater then number of servers, if clients have no heavy restrictions on number of outbound connections, then it would overload servers and deny access to blockchain data to some clients.

To illustrate, imagine situation where there is only one server on the network and many bitcoin clients, if clients can reserve as many server connections as they want that would for sure prevent some clients from connecting to the server.


---

### Answer by username_2 on 2016-12-01. Score: 1

the constants to set numbers of connections are in src/net.h

`static const int MAX_OUTBOUND_CONNECTIONS = 8;`

in the repo on github:
<https://github.com/bitcoin/bitcoin/blob/3bf06e9bac57b5b5a746677b75e297a7b154bdbd/src/net.h#L59>

change to what you like and recompile


---

