I'm using truffle (which uses pudding) to deploy contracts to my testrpc.

No I'm running a geth instance locally with:

geth --mine -rpccorsdomain "*" --ipcapi "admin,eth,miner" --rpcapi "eth,web3" --networkid 1100 --maxpeers 5 --minerthreads 1 --unlock "0xXXXXXXXXetc.." console

Now when I try to deploy my contracts, I get:

Invalid JSON RPC response: "Error: connect ECONNREFUSED at..."

What am I missing here? How does truffle/pudding identify itself to the node, when it deploys? (i.e. truffle deploy) I can't see anything to configure this.

3 Answers 3


Turned out that the default port is not 8545, and had to add these options:

--rpc --rpcport 8545

  • Actually, the default port is 8545, but you need to use the --rpc flag to enable RPC connections Sep 1, 2016 at 22:56

Contract compilation is described in detail here; an example may look like:

./geth --datadir ~/eth/ --loglevel 6 --logtostderr=true --rpc --rpcport 8100 --rpccorsdomain '*' --mine console  2>> ~/eth/eth.log
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"],"id":1}'

(make sure you are connecting to the right ports).

Contract deployment is shown here:

source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"
// compile with solc
contract = eth.compile.solidity(source).test
// create contract object
var MyContract = eth.contract(contract.info.abiDefinition)
// extracts info from contract, save the json serialisation in the given file, 
contenthash = admin.saveInfo(contract.info, "~/dapps/shared/contracts/test/info.json")
// send off the contract to the blockchain
MyContract.new({from: primaryAccount, data: contract.code}, function(error, contract){
  if(!error && contract.address) {
    // calculates the content hash and registers it with the code hash in `HashReg`
    // it uses address to send the transaction. 
    // returns the content hash that we use to register a url
    admin.register(primaryAccount, contract.address, contenthash)
    // here you deploy ~/dapps/shared/contracts/test/info.json to a url
    admin.registerUrl(primaryAccount, hash, url)
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Jul 12, 2016 at 15:41
  • Done, edited the answer.
    – Sebi
    Jul 12, 2016 at 16:24
  • The question is more about how truffle identifies itself to a node, i.e. which account is it using to deploy (when doing truffle deploy) Jul 25, 2016 at 8:43

First of all,you need to add a rpc port in your geth as : geth --rpc --rpcport "portnumber".
Then in your truffle project folder there will a file named truffle.js.You need to update the rpc section as section

rpc: {
   host: "localhost",
   port: portnumber

Thus it will be connected to tehy node running locally on your system.Now you just need to run the command truffle deploy and your contracts will be deployed on your private blockchain. Error is appearing because of the default value set in truffle.js file which is trying to connect a local node running on the port 8545. I hope it will resolve your issue.

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.