37

At this moment, blockchain.info has over 1,900 nodes connected to their bitcoin client.

I have been running an m1.small ubuntu 12.04 server and bitcoind for ~4 days straight now with no reboots. My bitcoind client still only shows ~60 connections maximum when performing a "./bitcoind getinfo" command.

How can I achieve 1,000+ connections to my bitcoind client? And is it "worth it" in your opinion?

EDIT: I have re-started my bitcoind client with the -maxconnections=1000 and -timeout=15000 parameters but after ~12 hours of running bitcoind, the number of connections is only up to ~40. And I don't seem to be maxing out my CPU, RAM, or bandwidth just yet.

EDIT 2: I have not seen a "connected time" over 8 hours in the list provided by blockchain.info so that tells me they must restart their server every 8 hours or so. Either that, or connections drop and refresh after 8 hours? I am beginning to think that blockchain.info keeps track of IP addresses running bitcoin in a database of sorts... and forefully connects to them every time their bitcoind reboots. Am I right?

7
  • 6
    Blockchain runs multiple bitcoind nodes and the networking components were also modified to use boost::asio rather posix sockets. you should be able to get at least 1024 connections with standard bitcoind though.
    – user418
    Commented Mar 4, 2013 at 19:22
  • 1
    Any idea on what might be holding me back from achieving 1,024 connections on my bitcoind? I don't seem to be maxing out my CPU, RAM, or bandwidth just yet.
    – user3145
    Commented Mar 4, 2013 at 21:53
  • Bitcoin Unlimited has an option -maxoutconnections that allows you to increase outgoing connections to peers. It defaults to 8 but you can set it to something higher without having to recompile the node from modified source.
    – greatwolf
    Commented Oct 29, 2016 at 20:23
  • 1
    When I set -maxconnections to something high I get the following error: > Warning: Reducing -maxconnections from 4096 to 865, because of system limitations. so it seems like one can not even go super high with incoming connections as well? Commented Jun 18, 2017 at 10:49
  • @greatwolf is bitcoin unlimited works for bitcoin or bitcoin cash ?
    – user10603
    Commented Sep 7, 2017 at 13:25

6 Answers 6

15

The bitcoind client has a maxconnections configuration option. The client launched With -maxconnections=N will allow up to N incoming connections to be established simultaneously.

Perhaps you may need to increase the connection timeout for that many connection attempts from a single (possibly underpowered) node. Perhaps set it to like 15 seconds (15000 ms).

-timeout= Specify connection timeout in milliseconds (default: 5000)

[Edit: Pieter Wuille's answer gets you further there. -addnode will let you force new outgoing conections to nodes when you have their IP addresses.]

3
  • I will re-start my bitcoind client now with the timeout increased to 15 seconds as suggested as well as the -maxconnections=1000 and get back to you.
    – user3145
    Commented Mar 4, 2013 at 21:54
  • 6
    So after 7 hours of running bitcoind with a 15 second timeout and 1,000 max connections.. I was at 32 connections at one point but have now dropped to 28, so I doubt adding the maxconnections or the timeout variable did much at all unfortunately. In fact I think it may have hindered the number of connections I would normally have after 7 hours.
    – user3145
    Commented Mar 5, 2013 at 5:16
  • does maxonnections in the .conf override what's in code as the max?
    – Sun
    Commented Mar 8, 2019 at 1:24
23

Bitcoin by default will not make more than 8 outgoing connections, and -maxconnections only controls how many incoming connections you allow. Feel free to set this higher, but it will take time before others connect to you in large numbers.

Please don't change this, as there is no need. Connectable peers on the network are a scarce resource, and essential to the decentralization. If people go try connect to all of them like some sites do, we'll very quickly run out.

In case you're a merchant or miner, you perhaps want to set up a few fixed connections to trusted others (see the -addnode command line/config option), but having more connections does not mean stronger verification (the reference client always verifies everything) or even faster relaying (as you'll slow down by distributing new blocks and transactions to all your peers). It is mostly a matter of providing a service to the network.

3
  • 2
    After 4 days of running my box with -maxconnections=1000, I was still only at ~50 connections. I have not seen a "connected time" over 8 hours in the list provided by blockchain.info so that tells me they must restart their server every 8 hours or so. Either that, or connections drop and refresh after 8 hours?
    – user3145
    Commented Mar 5, 2013 at 18:23
  • I'm sure they have a custom infrastructure that creates thousands of outgoing connections. Bitcoind never creates more than 8. As I said, there is no need for more. Commented Mar 5, 2013 at 23:27
  • It could be also counted from aggregate nodes across the country and not just from one client.
    – Tek
    Commented Jan 30, 2021 at 6:43
22

The given answers don't answer the question. Even though it might not makes sense to achieve a thousand connections, here's how to do that on Debian. You want to make some slightly changes in the code and recompile bitcoind:

Get required packages for compiling:

$ aptitude install git make build-essential libssl-dev libboost-all-dev libdb-dev libdb++-dev libminiupnpc-dev

Clone the git repository (make sure the version is the most recent branch):

$ cd /usr/src
$ sudo git clone -b 0.8.4 https://github.com/bitcoin/bitcoin
$ cd bitcoin/src

Edit the net.cpp file:

@@ -27,7 +27,7 @@
 using namespace std;
 using namespace boost;

-static const int MAX_OUTBOUND_CONNECTIONS = 8;
+static const int MAX_OUTBOUND_CONNECTIONS = 1000;

 bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);

@@ -1533,7 +1533,7 @@
             OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
             MilliSleep(500);
         }
-        MilliSleep(120000); // Retry every 2 minutes
+        MilliSleep(5000); // Retry every 5 seconds
     }
 }

1.) By changing MAX_OUTBOUND_CONNECTIONS, the client will go on connecting until it reaches 1000 proactive connections.

2.) By changing the sleep timeout new connections are tried more frequently.

Compile and install bitcoind:

$ sudo make -f makefile.unix
$ sudo mv bitcoind /usr/bin

Don't forget to set the maxconnections in bitcoin.conf:

maxconnections=1000

Start bitcoind and your done. The client will make lots of connections really fast.

Disclaimer: As Pieter Wuille pointed out, it can harm the network to run a modified client like this one. Please use this solution for research purposes only and not as a permanent solution.

4
  • 9
    I don't want to downvote because you're indeed actually answering the question, but I really strongly want to stress that doing this is a horrible idea and unnecessary. See my answer for why. Commented Aug 25, 2013 at 23:37
  • 3
    @Pieter Wuille: How do you want to stop people from exploiting the Bitcoin network? Just telling them "hey, you bad boys, don't do this or that"? That's not going to work...
    – Kozuch
    Commented Dec 16, 2013 at 10:39
  • 6
    I'm not trying to stop bad guys - they're a fact of life, and I'm sure we can deal with a few. What I want to avoid is people incorrectly assuming that more connections is better for them and/or the network. Commented Dec 16, 2013 at 23:39
  • 2
    This is the real answer!
    – Felipe
    Commented Mar 12, 2014 at 11:29
3

As nobody seems to have mentioned it I'll chip in for future reference. If your bitcoind node is behind a router/NAT then you can only connect to others, they cannot connect to you. Let's assume most people are in that situation, which makes most nodes unconnectable (directly at least). If you open up your node port on your router then every bitcoind node out there will be able to connect to you if they wish rather than your node only being able to connect to others who have opened their port. The same applies to Bittorrent and other p2p systems.

1

Why do you need 1,000+ connections?

By default bitcoind cannot have more than 125 connections. You need to start bitcoind with the parameter -maxconnections=<n> or set maxconnections=<n> in bitcoin.conf to be able to connect to more peers.

3
  • 8
    Why?! Why not should be the real question! If you must know, I want to have the most verified blockchain in the world.
    – user3145
    Commented Mar 4, 2013 at 19:06
  • 5
    "The most verified"? That makes no sense. Every node at the same block height and block hash is equal. And yours may have a blockchain fork that eventually becomes orphaned. Commented Mar 4, 2013 at 20:38
  • 7
    Sorry for the typo, I'm not up to speed on the entire bitcoin lexicon just yet. If not the most verified, then I want to be the fastest at recognizing new transactions. That is what I meant.
    – user3145
    Commented Mar 4, 2013 at 21:52
-4

To check whether you allow incoming, use this: https://bitnodes.21.co There is a button to check your ip and if it results in green, you are fine to have incoming connection. Once you have that, I was told you can have more outgoing connection. Good luck.

1
  • That's not an answer to the question. Commented Jun 30, 2016 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.