API Connection Refused - General - Algorand

API Connection Refused

post by peterd on Nov 23, 2020

I keep getting a ‘connection refused’ error when I try to connect to my algorand node (running on Ubuntu 18.04) over my LAN.

So far I have…

const algosdk = require(‘algosdk’);

const algodToken = ‘API Key’;
const algodServer = ‘http://LAN IP’;  
const algodPort = 8080;
const algodClient = new algosdk.Algodv2(algodToken, algodServer, algodPort);
(async () => {
    let status = await algodClient.status().do();
    console.log('Algorand node status: %o', status);
})();

I am stuck and not sure what to do next to troubleshoot my problem, any advice is much appreciated?

post by JasonW on Nov 23, 2020

are goal commands working on the node? Ie goal node status -d data

post by peterd on Nov 23, 2020

Yes the ‘goal node status -d data’ command is working.

post by JasonW on Nov 23, 2020

any chance you can run that node code on the server to make sure that is working?

post by fabrice on Nov 23, 2020

Have you changed the EndpointAddress in config.json to allow connections from 0.0.0.0 instead of just localhost?

post by peterd on Nov 23, 2020

No I had not done this step. This fixed my issue, thanks for your help!

post by peterd on Nov 23, 2020

I was able to reach the api when I ran the code from the node server. Once I properly set the EndpointAddress in config.json, as @fabrice pointed out, the code worked. Thanks for your help.