I have setup a private Ethereum system using geth. And am running a client that uses a web3.js file to connect to the Ethereum system. While trying to send a transaction or call some contract function, I get an error -

(node:500) UnhandledPromiseRejectionWarning: Error: Returned error: exceeds block gas limit

I have started the Ethereum nodes with a higher gas limit using targetgaslimit and also from the genesis file.

Here's how I started ethereum:

geth --datadir /root/.ethereum/geth/datastore/datadir --networkid 15 --rpc --rpcapi web3,eth,personal,miner,net,txpool --rpcaddr <ip> --targetgaslimit=9000000000000 --gasprice '1' console

Snippet from genesis.json:

difficulty" : "0xB",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",

As you can see, the gas limit is set to a higher value. Now, I have a smart contract deployed on the Ethereum network -

pragma solidity ^0.4.13;

contract Simple {
  uint public _num = 2;

  function Simple(uint _inNum) public {
        _num = _inNum;

  function setNum(uint _num2set) public {
        _num = _num2set;

  function getNum() public constant returns (uint) {
        return _num;

  function getArea(uint _side) returns (uint) {
        return (_side * _side);

  function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) {
    o_sum = _a + _b;
    o_product = _a * _b;

  function multiply(uint _a, uint _b) returns (uint) {
    return _a * _b;

Now, I am trying to run a web3 client to connect to the Ethereum node.

I have written some sample application JS code that connects to an Ethereum node -

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider(""));

Now, I am trying to send a transaction or call one of the functions in the Ethereum smart contract by running the following command on the Node console-

simpleContract.methods.getNum().send({from: '0x41088ec8B25cc67c2558261B62FeD73f8B26ccc2', gasPrice: '0x1', gasLimit: '0x77359400'}).then(console.log)

But I always get exceeded gas limit error. From what I see, this transaction shouldn't exceed the gas limit at all. The gas limit while starting geth,as well as in the command are reasonable. when I check gas limit also, I get a reasonable number -

Promise {
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> { difficulty: '635410',
  extraData: '0xd88301080f846765746888676f312e31302e31856c696e7578',
  gasLimit: 8000000,
  gasUsed: 0,

Here's the complete error I see:

> simpleContract.methods.getNum().send({from: '0x41088ec8B25cc67c2558261B62FeD73f8B26ccc2', gasPrice: '0x1', gasLimit: '0x77359400'}).then(console.log)
Promise {
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> (node:500) UnhandledPromiseRejectionWarning: Error: Returned error: exceeds block gas limit
    at Object.ErrorResponse (/node_modules/web3-core-helpers/src/errors.js:29:16)
    at /node_modules/web3-core-requestmanager/src/index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (/node_modules/web3-providers-http/src/index.js:91:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
(node:500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 62)

Any pointers on what the issue could be. I even tried explicitly setting gas and gas price: gas: '0x800000', gasPrice: '0x1', gasLimit: '0x77359400', but that did not work either. In fact, if I set gas to a lower value, I get an error:

(node:500) UnhandledPromiseRejectionWarning: Error: Returned error: insufficient funds for gas * price + value

Please suggest.


  • What version of web3js are you using?
    – vhie
    Oct 8, 2018 at 7:35
  • @vhie - I'm on 1.0.0
    – Omi
    Oct 8, 2018 at 7:41
  • 1.0.0-beta.36 to be specific. > web3.version '1.0.0-beta.36'
    – Omi
    Oct 8, 2018 at 7:45

1 Answer 1


In your genesis file you have as gas limit 0x2fefd8. Your --targetgaslimit is 9000000000000 and and your method call has gasLimit: '0x77359400'

The point is: your targetgaslimit will not take effect immediatly. The block gas limit will grow towards this value slowly.

To check the gas limit of the last block, call eth.getBlock("latest").gasLimit

This is also the max. value you may pass to your function call, otherwise the transaction will be rejected.

  • thanks for the response. I already tried this: web3.eth.getBlock("latest").then(console.log) and get - gasLimit: 8000000. Yet I see this error. If I try to lower the gas value, I get a different error: error: insufficient funds for gas * price + value
    – Omi
    Oct 8, 2018 at 7:48
  • one more thing - mine is a private ethereum network with just 2 nodes. Will my gas limit also grow over time?
    – Omi
    Oct 8, 2018 at 7:49
  • 1
    Yes. You started with a much smaller value in genesis, so it will slowly grow to targetgaslimit even in a private network. If your latest block gasLimit is 8000000 then you should change your method call and set a gasLimit <= 8000000 (currently it's at 20000000).
    – ivicaa
    Oct 8, 2018 at 7:51
  • 1
    Update on this: I got it to work. First eliminated the gaslimit and gas values and used a different account. This is what I did: simpleContract.methods.getNum().send({from: '0xfEECE2490Ea0240BF8C11B224Fd55Eef74669CCa'}).then(console.log, console.log)
    – Omi
    Oct 8, 2018 at 9:15

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.