You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bitcoin-cli: Provide a better error message when bitcoind is not running
Before this patch:
```
$ bitcoin-cli -testnet echo 'hello world'
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (/root/.bitcoin/bitcoin.conf)
```
After this patch:
```
$ bitcoin-cli -testnet echo 'hello world'
error: Could not connect to the server 127.0.0.1:18332
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
```
// Try fall back to cookie-based authentication if no password is provided
318
319
if (!GetAuthCookie(&strRPCUserColonPass)) {
319
-
throwstd::runtime_error(strprintf(
320
-
_("Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (%s)"),
throwCConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error));
363
-
elseif (response.status == HTTP_UNAUTHORIZED)
364
-
throwstd::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
throwCConnectionFailed(strprintf("Could not connect to the server %s:%d%s\n\nMake sure the bitcoind server is running and that you are connecting to the correct RPC port.", host, port, responseErrorMessage));
365
+
} elseif (response.status == HTTP_UNAUTHORIZED) {
366
+
if (failedToGetAuthCookie) {
367
+
throwstd::runtime_error(strprintf(
368
+
_("Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (%s)"),
0 commit comments