I built a private chain on my computer using geth and I want to interact with it using web3.py. But there was something wrong.

I started the private chain(containing only one node) with the command

$ geth --datadir datadir --rpc --rpcport 8545 --port 30301 --ipcpath /tmp/geth.ipc --rpccorsdomain '*' --unlock 0

Having started the chain, I was able to use the environment in remix IDE via RPC. Then I followed the docs of web3.py and wrote some simple code:

from web3 import Web3, HTTPProvider
w3 = Web3(HTTPProvider('http://localhost:8545'))

What upset me was that the w3.eth.blockNumber worked just fine but the listAccounts didn't. Here is a picture of the error message : via RPC

Some info: OS: ubuntu16.04 geth: 1.8.2 web3.py: 3.16.5

A noobie here, please help T_T. I googled this but didn't find similar problems (maybe this is too simple?).

  • i'm not familiar with the python framework, but my instinct says to try w3.eth.accounts to fetch accounts
    – Chris
    Commented Mar 17, 2018 at 18:08
  • The personal API can be abused pretty easily over HTTP, so it is typically disabled by default over HTTP. Check geth --help for enabling personal api's over HTTP (but please don't do this on mainnet, with real assets at stake).
    – carver
    Commented Mar 21, 2018 at 17:52

1 Answer 1


Thanks for the comments @carver and @Chris.

Just as carver said in the comments, the problem is that personal api is not enabled by default and I didn't add the --rpcapi flag.


option 1 : start geth with the flag --rpcapi personal,web3,eth and any other flags necessary.

option 2 : use the eth.accounts, which is enabled by default.

  • i already had --rpcapi personal,web3,eth flag, but still can't access through personal but eth works, is it an error or wrong api instruction from web3py?
    – TomSawyer
    Commented Jun 12, 2019 at 16:08

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.