1

I am trying to deploy a contract to the mainnet. My truffle.js looks like this:

require('babel-register')
module.exports = {
  networks: {
    "live": {
      network_id: 1,
      host: 'localhost',
      port: 8546
    }
  },
  rpc: {
    host: "localhost",
    port: 8545
  }
};

I have connected to the mainnet in geth (just with geth and geth attach though I've also tried geth --rpcport 8546 --rpcaddr 127.0.0.1 for example). My blockchain is fully up to date (running eth.blockNumber will show I'm at the latest block or close to it).

Running the following command to deploy my contract:

truffle migrate --network live

Will result in the following error:

Invalid JSON RPC response: ""

This problem is truffle isn't connecting to the mainnet at all. I've successfully deployed to the ropsten test network using truffle when geth is connected to that, so am not sure why the mainnet isn't working (when deploying to ropsten I have basically the same truffle.js as above except network_id: 3 instead of network_id: 1, and the same command to deploy the contract except with --network ropsten instead of --network live).

  • Have you unlocked and funded your default mainnet account? – Jakub Wojciechowski Jul 25 '17 at 12:15
  • Yes, and the account has ether in it as well. – ZhouW Jul 25 '17 at 12:22
  • Can you try with --rpcapi "db,eth,net,web3,admin,personal" in your command line? (admin, and personal should not be necessary but I don't know what if truffle requires them). – Ismael Jul 25 '17 at 13:09
  • still not working – ZhouW Jul 26 '17 at 7:42
1

Running netstat -an showed the port I though I was running the mainnet on (8546 here) wasn't active. Running the mainnet in geth on port 8545 (like the testnet) and changing truffle.js to look at port 8545 allowed truffle to connect to it.

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.