1

I have been able to successfully deploy contracts on the ethereumjs testrpc with truffle without any issues. Now I wanted to do the same on a remote node running geth 1.6.1 but it gives me a JSON RPC error every time i try to run truffle migrate. There are no issues with ports and all ports are open. Tried setting up a fresh data directory , but same issue persists

command used in starting the geth client :-

geth --datadir /home/ubuntu/privatenet/test1 --networkid "1234" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3,web3_extended" --rpc --port 30310 --rpcaddr "0.0.0.0" --rpcport 8110 --rpccorsdomain="*" --nat "any" --unlock '0,1' console 2>> /home/ubuntu/privatenet/test1/eth8.log

my truffle.js file is as follows:-

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    },
    geth: {
      host: 'http://10.0.0.241',
      port: 8110,
      network_id: '1234', // Match network id
      from: '0x7824b8756cfa5131ead88e190e8adb10546fefaf' // account 0 
        (default account which has been already unlocked)
    }
  }
};

command used: truffle migrate --network geth

Result:

Compiling .\contracts\ UtilityEVEC.sol...
Compiling .\contracts\TokenWallet.sol...
Compiling .\contracts\contractContainer.sol...
Writing artifacts to .\build\contracts

Using network 'geth'.

    Running migration: 1_initial_migration.js
    Error: Invalid JSON RPC response: ""
        at Object.InvalidResponse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\node_modu
    les\web3\lib\web3\errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Administrator\AppData\Roaming\npm\node_module
    s\truffle\node_modules\web3\lib\web3\httpprovider.js:115:32)
        at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\Administrator\AppData\Roaming\npm\node_modules\
    truffle\node_modules\xhr2\lib\xhr2.js:64:18)
        at XMLHttpRequest._setReadyState (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\no
    de_modules\xhr2\lib\xhr2.js:354:12)
        at XMLHttpRequest._onHttpRequestError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truff
    le\node_modules\xhr2\lib\xhr2.js:544:12)
    at ClientRequest.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\node_m
    odules\xhr2\lib\xhr2.js:414:24)
        at emitOne (events.js:96:13)
        at ClientRequest.emit (events.js:188:7)
        at Socket.socketErrorListener (_http_client.js:310:9)
        at emitOne (events.js:96:13)
  • Did you try removing datadir and instantiating the genesis block once again? These are the steps to set up privatenet from scratch - ethereum.stackexchange.com/questions/125/… Also, check if port 8110 is open at your remote machine. – Sanchit May 23 '17 at 18:40
  • Yea tried doing that today .. set it up from scratch , but still getting the same error. There are no issues with ports. Can't really find a reason why this is happening. – Shourie Ganguly May 25 '17 at 10:34
  • --rpcaddr "0.0.0.0" just noticed this, I guess you should change this with 10.0.0.241 – Sanchit Jun 3 '17 at 20:58
2

I had the same error which was due to a wrong IP in host parameter. This error is apparently throw when truffle is unable to establish the connection to the network node.

In your truffle.js configuration you should only set the hostname, not the protocol. Ie:

You should have "10.0.0.241" instead of 'http://10.0.0.241'

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.