Can’t get your private Ethereum blockchain to work?
There’s not a lot of documentation on getting private blockchains working other than some very basic setup guides. There’s very little troubleshooting information out there for what to do when suddenly your client won’t mine, or when adding a peer returns true, but the peer never actually adds and you have no idea why.
If you wanted to skip the problems
and just need a working blockchain with free node hosting, I’d highly
recommend just using a free crypto coin generator like Coinpress.cc if you need a full blockchain or one of the dozens of token generators if you just want an ERC20 token.
Why would you even need a private blockchain?
If you’re wanting to do transactions of real money securely, you’re better off on the Ethereum Mainnet. You’d want to use a private blockchain if you’re creating your own crypto coin, don’t want to have to spend time or money to acquire similarly functional cryptocurrency, or you need to store more than trivial amounts of data to a blockchain while still retaining all the other functionality that protocol has to offer.
But problems can come up when you’re trying to do that, and there aren’t nearly as many resources out there for private test blockchains. In this article I’ll cover some common issues and tips to bringing up your private blockchain.
NOTE: Make sure you disable the Ethereum discovery protocol!
Ethereum will waste a bunch of bandwidth if you’re using a private blockchain, even behind a NAT if you aren’t including the —nodiscover command, especially when running multiple nodes.
Your Ethereum node won’t connect to other peers.
Make sure you’re initializing your genesis file
- Make sure you run geth once to initialize the blockchain before attempting to run it in console mode with “geth —datadir ./MyCoin init ./MyCoin.json”
- Specify the genesis file when you start it in console mode with “geth console —datadir ./MyCoin init ./MyCoin.json”
Check for any extra spaces in your commands if you’re scripting anything.
Geth will often still start and appear to be working while ignoring your commands.
To test if you’re initializing the right genesis file, try CPU mining (if your blockchain difficulty is low enough).
If you’re accidentally using the Ethereum mainnet genesis file somehow, you won’t be able to mine any significant amount of coins.
You get an error that the data directory is already in use.
Check that geth isn’t already running.
- On Windows: Look in task manager for the process geth.exe. Right click > End Task
- In Linux: ps aux | grep geth sudo kill -9 <process id returned>
Try specifying a new data directory and see if it works.
- If it does, your data directory may be corrupted.
Note: Make sure that you’re keeping ports unique to instances!
If you’re trying to start multiple instances with the same default ports, the nodes will fail to start up.
Can’t start multiple Ethereum nodes on the same computer or server.
- Make sure you’re passing —ipcdisable to the servers if you won’t be using IPC, or specify the IPC port as a command line argument.
- Make sure you’re choosing different data directories on all instances.
Mining doesn’t work.
Make sure you have an account to mine to.
- Use the console command “eth.accounts”. This should list out all the accounts you have. If the list is empty, run the console command personal.newAccount()
- Make sure you have an Etherbase set with the console command miner.setEtherbase(web3.eth.accounts)
Make sure the difficulty isn’t too high.
- Are you using CPU mining? CPU mining, especially solo CPU mining, is the slowest way to mine. At even moderately high difficulties, CPUs start becoming very ineffective.
- How many other users are there? If there is a lot of mining, the Ethereum protocol will automatically up the difficulty to balance the block rewards to around every 12-15 seconds.
Make sure you’re on the right blockchain
- Check if your miner is generating very large DAG files. This could mean you’re accidentally generating DAG files for the Ethereum Mainnet. New private testnet DAG files should be fairly small, but if you see .DAG files accumulating above 3GB, or notice that CPU mining is taking a really long time just to get started, it’s likely you’re accidentally hitting the Mainnet somehow.
miner.start() returns null
- Try miner.start(1) and if that works. The 1 is for 1 thread and you can increase it accordingly.
- Make sure the command eth.accounts returns at least one account.
- Make sure there’s an etherbase listed in the console command eth.coinbase