0

I am running geth -rpc and node to directly interact with the blockchain. When executing a large amount of requests I noticed the following error:

http: Accept error: accept tcp 127.0.0.1:8545: accept: too many open files; retrying in 5ms

How can I configure geth to handle more connections? My code is:

var Web3 = require("web3")
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

// first
txs = [];
// second

for (i = 0; i < 100; i++) {

web3.eth.getBlock(4000000+i, function(error, block) {
        if(!error) {
            for (j = 0; j < block.transactions.length; j++) { 
            web3.eth.getTransaction(block.transactions[j], function(error, transaction) {
                    if(!error) {
                        txs.push({block: transaction.blockNumber, from: transaction.from, to: transaction.to, value: transaction.value.toNumber(), id: block.transactions.indexOf(transaction.hash)})
                    }
                    else
                    console.error(error);
                });
            }
        }
        else
        console.error(error);
    });
}
0

If you're running on Ubuntu or a similar flavour of Linux, then the per-user (soft) limit on the number of file descriptors is 1024.

$ ulimit -n
1024

You have several options to get around the error you're seeing, including increasing both the soft and hard limits for the user in question.

There are details of how to go about doing this in a previous answer.

(You might also find this thread useful: Common useful JavaScript snippets for geth)

  • It is not possible, at least up to version 1.8.13-stable-225171a4 , to increase the number of open files greater than 2048. You can increase them to any number you like in the unix system, user or process limits, but geth limits it back down to 2048. We constantly suffer from too many open files error, and as far as we know, there is no solution or workaround other than changing the limits in a constant loop in the background. – John Little Aug 7 '18 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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