<p>Without anything in the log, it's difficult to day. But here are a few suggestions what could try to find out the cause of the error:</p>

<ul>
<li>Do you have write permission on the <code>wallet.dat</code> file in your <code>.bitcoin</code> directory?</li>
<li>Is the wallet locked with a passphrase? Then you need to unlock it (would probably give another error message but worth asking).</li>
<li>Did you set the <code>disablewallet</code> option either in command line or configuration file?</li>
<li>Is your wallet possibly locked due to a <code>-reindex</code> operation?</li>
</ul>

CC BY-SA 4.0
2019-08-04T09:39:35.200Z
2019-08-04T09:39:35.200Z
guggero
<p>leave away the "" around the key (and the label)?</p>

CC BY-SA 3.0
2014-02-18T10:56:57.863Z
Same issue with or without the quotes.
dooode
CC BY-SA 3.0
2014-02-18T20:05:06.680Z
Not a trace of the error in  /root/.bitcoin/debug.log  :(
dooode
CC BY-SA 3.0
2014-02-18T20:05:38.823Z
I have tried with a new user as well.
dooode
CC BY-SA 3.0
2014-02-18T07:16:43.143Z
2014-02-18T07:27:51.817Z
2014-02-18T07:27:51.817Z
dego
<p>I am in a special situation where I need to import my private key credentials and basically restore a wallet to bitcoind. bitcoind is running and I do have an rpc user/pass and server=1 in the bitcoind.conf, but no matter what I do, when I try and import the key I get the following error.
There is no password nor encryption on the wallet.</p>

<pre><code>root@coined:/home#  bitcoind importprivkey "5JxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHjdCia9dt7" "root"
error: {"code":-4,"message":"Error adding key to wallet"}
</code></pre>

CC BY-SA 3.0
2014-02-18T15:30:51.310Z
Are there any useful messages in debug.log?  Also, FYI, if you run this on the command line, your private key is probably now logged in your shell's history file (perhaps ~root/.bash_history).
Nate Eldredge
CC BY-SA 3.0
2014-02-19T10:23:38.847Z
If you typed it up manually, you might have a typo in there or are missing a character? I once had a uppercase "S" instead of lowercase "s" in something and it took me forever to find it.
Murch
CC BY-SA 3.0
2014-02-19T22:36:58.247Z
@Murch copy/paste
dooode
<bitcoind><client><api><private-key>
Trying to import a private key into bitcoind
dooode
# Trying to import a private key into bitcoind

(Asked by: username_0 on 2014-02-18)

I am in a special situation where I need to import my private key credentials and basically restore a wallet to bitcoind. bitcoind is running and I do have an rpc user/pass and server=1 in the bitcoind.conf, but no matter what I do, when I try and import the key I get the following error.
There is no password nor encryption on the wallet.

```
root@coined:/home#  bitcoind importprivkey "5JxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHjdCia9dt7" "root"
error: {"code":-4,"message":"Error adding key to wallet"}

```

**Tags:** bitcoind, client, api, private-key

> **Comments:**
> **username_1**: Are there any useful messages in debug.log?  Also, FYI, if you run this on the command line, your private key is probably now logged in your shell's history file (perhaps ~root/.bash_history).  
> **username_2**: If you typed it up manually, you might have a typo in there or are missing a character? I once had a uppercase "S" instead of lowercase "s" in something and it took me forever to find it.  
> **username_0**: @username_2 copy/paste  

---

## 2 answers

### Answer by username_3 on 2019-08-04. Score: 1

Without anything in the log, it's difficult to day. But here are a few suggestions what could try to find out the cause of the error:

* Do you have write permission on the `wallet.dat` file in your `.bitcoin` directory?
* Is the wallet locked with a passphrase? Then you need to unlock it (would probably give another error message but worth asking).
* Did you set the `disablewallet` option either in command line or configuration file?
* Is your wallet possibly locked due to a `-reindex` operation?


---

### Answer by username_4 on 2014-02-18. Score: -2

leave away the "" around the key (and the label)?

> **Comments:**
> **username_0**: Same issue with or without the quotes.  
> **username_0**: Not a trace of the error in  /root/.bitcoin/debug.log  :(  
> **username_0**: I have tried with a new user as well.  

---

