I have two geth nodes, each has an account:

node1(IP: account1
node2(IP: account2

the two accounts are created using geth --datadir /root/chain/node1/data account new, the keystore files are generated and saved on each node.

I use web3 to attach node1 in nodejs environment:

const Web3 = require('web3');
const web3 = new Web3('');

and try to unlock account2 created on node2 before sending a token transaction like below:

await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

I got an error like below:

Error: Node error: {"code":-32000,"message":"no key for given address or file"}

I also tried if attach to node2 and the unlock process is correct.

const Web3 = require('web3');
const web3 = new Web3('');
await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

How can I unlock an account use web3 without the limitation of node connection?


  • did you test your code locally with ganache and checked if its working? since from the code posted i can see you are using a node on a remote server.
    – wandos
    Jun 12 '19 at 14:41
  • the code can work as I said in the post. the problem is how to unlock any account created in node1 when attaching node2 using web3 lib. If I have already known the private key, how to make web3 object aware of it. In this way, I should not need to call "we3.eth.personal.unlockAccount()"?
    – Ntydrm
    Jun 13 '19 at 1:42
  • I want to unlock an account created on remote node. the account's keystore file is also saved in that node.
    – Ntydrm
    Jun 13 '19 at 2:11
  • you will need to connect to that node directly by setting the web3 provider and then unlock your account.
    – wandos
    Jun 13 '19 at 5:06

The account files are located in /root/chain/node1/data/keystore folder (in your case), so you need to copy both keys to both nodes, because the accounts are local per node

  • Can I specify the path of keystore file when unlock account using web3.eth.personal.unlockAccount(account, "account password", unlocktime)? if possible, then I can put keystore file on other computer instead of /root/chain/node1/data/keystore folder
    – Ntydrm
    Jun 12 '19 at 8:31
  • The key files are local per node, so you just need to copy the files from the other comuter
    – KNK
    Jun 13 '19 at 9:35

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.