I am just getting started with Stellar. I run a node connected with test network with the following command.

docker run --rm -it -p "8000:8000" -v "/home/prashant/stellar/steler-node:/opt/stellar" --name stellar stellar/quickstart --testnet

I created an account and received some Lumens using friendbot.

Now when I try to connect to horizon using npm request module. I am able to query balance. This script works perfectly.

const request = require('request-promise');

const options = {
  method: 'GET',
  uri: 'http://localhost:8000/accounts/GD7HLQRVOFPYJBQ4HJY74LJZ5FXM5YPTZA55IKXZNSEPLF7UYEWDBJ4G',
  json: true // keep this true else you need to parse the response

        //account = JSON.parse(response);
        console.log('Balances for account: ' + account.account_id);
        account.balances.forEach(function(balance) {
          console.log('Type:', balance.asset_type, ', Balance:', balance.balance);
        console.log("Unable to get balance.");

But when I try to connect using SDK, check following script.

var StellarSdk = require('stellar-sdk');

const account1 = {

var server = new StellarSdk.Server('');

// the JS SDK uses promises for most actions, such as retrieving an account
server.loadAccount(account1.publicKey).then(function(account) {
  console.log('Balances for account: ' + account1.publicKey);
  account.balances.forEach(function(balance) {
    console.log('Type:', balance.asset_type, ', Balance:', balance.balance);
    console.log("error occured in getting balance");

I get error:

error occured in getting balance { Error: write EPROTO 139981321324352:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:

at _errnoException (util.js:999:13)
at WriteWrap.afterWrite [as oncomplete] (net.js:883:14) errno: 'EPROTO', code: 'EPROTO', syscall: 'write' }

However I have tested the later script connecting to setller's test node : https://horizon-testnet.stellar.org and it worked like charm.

Did I miss anything while setting up the node? Or I am calling the functions in wrong way?

Edit 1: I tried using https in my url to horizon. I got hit by error:

throw new Error("Cannot connect to insecure horizon server");


2 Answers 2


Okay. So found the solution with help of @Bartek Nowotarski.

My local horizon didn't have SSL certificate. So I had to either

  • add SSL to the horizon
  • Use it without SSL: var server = new StellarSdk.Server('', {allowHttp: true});

Not sure why this was not documented anywhere.


Or you may add this line in your JS:


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.