Go-Ethereum Error – Fixing ‘Datadir Already Used’ Issue

errorgo-ethereum

I noticed that geth stopped running on my system, so I tried restarting it but got the following error:
Fatal: Error starting protocol stack: datadir already used by another process

I checked whether there is another active instance of geth by running ps aux but found nothing. So I'm not sure how the directory can possibly be used by another process. Any ideas for debugging this situation?

Best Answer

If you're sure that geth is not already running, check for the presence of a LOCK file in the geth subdirectory of your data directory. Under Ubuntu this will be ~/.ethereum/geth.

I have experienced a rogue LOCK that caused this issue - I'm not sure why, possibly the normal shutdown of the previous geth session was distured.

Remove the Lockfile Debian/Ubuntu

Remove (or rename) ~/.ethereum/geth/LOCK and restart geth.

# Check that geth is not already running:
ps aux | grep geth

# geth not running - Check for presence of LOCK
test -e  && echo LOCK exists || echo LOCK does not exist

# LOCK exists, but geth isn't running so get rid of LOCK
# Rename to be safe - change back if you mess something up
mv ~/.ethereum/geth/LOCK ~/.ethereum/geth/xLOCK

Now try to start geth.

Related Topic