<p>Figured it out. Turns out that (at least on Bitcoind 0.8.1 on Ubuntu), specifying the conf file when starting bitcoind doesn't do anything. I was starting it with:</p>

<pre>
bitcoind -daemon -conf=./bitcoin.conf 
</pre>

<p>from a bitcoin directory I had created /home/vijay/btc/. But bitcoind automatically uses the conf file in ~/.bitcoin/bitcoin.conf and mine was being completely ignored. Not sure what the point of the "-conf" option is!</p>

<p>So the solution was just to add my rpc username and password to the default conf file, which fixed the authorization failed error.</p>

CC BY-SA 3.0
2013-05-04T16:42:56.800Z
You can use --datadir instead.
Tom van der Woerdt
CC BY-SA 3.0
2016-04-10T01:48:41.123Z
Sounds like a bug! Did you report it?
Noldorin
CC BY-SA 3.0
2013-05-04T15:10:22.770Z
2013-05-04T15:10:22.770Z
Vijay Boyapati
<p>I'm trying to make a simple request to bitcoind using perl I followed the example from the <a href="https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29#Perl" rel="nofollow">API reference</a>, but it fails saying "401 Authorization Required"</p>

<pre>
#!/usr/bin/perl -w 

use JSON::RPC::Client;
use Data::Dumper;

my $client = new JSON::RPC::Client;

$client->ua->credentials(
    'localhost:8332', 'jsonrpc', 'bitcoinrpc' => 'mybitcoinrpcpassword'  # REPLACE WITH YOUR bitcoin.conf rpcuser/rpcpassword
    );

my $uri = 'http://localhost:8332/';
my $obj = {
    method  => 'getinfo',
    params  => [],
};

my $res = $client->call( $uri, $obj );

if ($res){
    if ($res->is_error) { print "Error : ", $res->error_message; }
    else { print Dumper($res->result); }
} else {
    print $client->status_line;
}
</pre>

<p>Am I missing something obvious? Thanks for any help!</p>

<bitcoind><json-rpc>
Authorization required error when accessing bitcoin using json RPC
Vijay Boyapati
# Authorization required error when accessing bitcoin using json RPC

(Asked by: username_0 on 2013-05-03)

I'm trying to make a simple request to bitcoind using perl I followed the example from the API reference, but it fails saying "401 Authorization Required"

#!/usr/bin/perl -w 

use JSON::RPC::Client;
use Data::Dumper;

my $client = new JSON::RPC::Client;

$client->ua->credentials(
    'localhost:8332', 'jsonrpc', 'bitcoinrpc' => 'mybitcoinrpcpassword'  # REPLACE WITH YOUR bitcoin.conf rpcuser/rpcpassword
    );

my $uri = 'http://localhost:8332/';
my $obj = {
    method  => 'getinfo',
    params  => [],
};

my $res = $client->call( $uri, $obj );

if ($res){
    if ($res->is_error) { print "Error : ", $res->error_message; }
    else { print Dumper($res->result); }
} else {
    print $client->status_line;
}

Am I missing something obvious? Thanks for any help!

**Tags:** bitcoind, json-rpc


---

## 1 answers

### Answer by username_0 on 2013-05-04. Score: 4 | Accepted answer

Figured it out. Turns out that (at least on Bitcoind 0.8.1 on Ubuntu), specifying the conf file when starting bitcoind doesn't do anything. I was starting it with:

bitcoind -daemon -conf=./bitcoin.conf 

from a bitcoin directory I had created /home/vijay/btc/. But bitcoind automatically uses the conf file in ~/.bitcoin/bitcoin.conf and mine was being completely ignored. Not sure what the point of the "-conf" option is!
So the solution was just to add my rpc username and password to the default conf file, which fixed the authorization failed error.

> **Comments:**
> **username_1**: You can use --datadir instead.  
> **username_2**: Sounds like a bug! Did you report it?  

---

