I am trying to import a p2sh address as watch-only:

bitcoin-cli importaddress <P2SH ADDRESS> true true

for which the command seems to execute, pause, then after a few minutes give me the error message:

error: couldn't connect to server: unknown (code -1) (make sure server is running and you are connecting to the correct RPC port)

Why is this not working for me?

2 Answers 2


I believe the issue is that you forgot the label parameter. According to the RPC help documentation, the parameters for importaddress should be:

 importaddress "address" "label" rescan p2sh

You have used "address", rescan and p2sh but not label, so the error is likely due to an issue converting the parameters you provided into the ones it expected.

But the fact that the error message is so hard to understand / unrelated to the actual error is a bug, please open an issue on github here: https://github.com/bitcoin/bitcoin/issues

  • That is looking to be the problem, so far. It wants a script instead of an address after adding a label. I will report the issue.
    – user31364
    Mar 29, 2018 at 0:08
  • @BrettDoffing it should not require the script, that defeats half the purpose of watch-only :)
    – meshcollider
    Mar 29, 2018 at 0:14
  • I know, right?!
    – user31364
    Mar 29, 2018 at 0:14

for some reason bitcoin-cli requires bitcoin.conf to be setup before it can work. To do this, you can go to your bitcoin data directory and add the following:

name the file bitcoin.conf then add the config file or you can just add: rpcuser=Randomusername rpcpassword=randompassword server=1 daemon=1 listen=1

  • rpc commands work for everything else.
    – user31364
    Mar 28, 2018 at 23:43
  • hmm try add that and see if it work cause i do have the same issue when i didnt setup the bitcoin.conf
    – zhiyan114
    Mar 28, 2018 at 23:44
  • my .conf is setup just fine, unless you can give me a specific reason why listen=1, or daemon=1 need to be set for this specific problem.
    – user31364
    Mar 28, 2018 at 23:49
  • I mean i added all to make sure because listen usually stands for to listen the port while daemon usually refers to a background server thing. Try add it and see if it solves and if not u can then remove it.
    – zhiyan114
    Mar 28, 2018 at 23:50
  • btw that error you have usually means that bitcoin-cli cannot connect to json-rpc with bitcoin-daemon or bitcoin core.
    – zhiyan114
    Mar 28, 2018 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy