API Connection Refused

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…

  • Checked $ALGORAND_DATA/algod.net to find the API endpoint (Running on 8080)
  • Copied the API key from $ALGORAND_DATA/algod.token to my code
  • Opened port 8080 for all incoming connections
  • Ensured that algod was listening on 8080 using sudo netstat -tulpn

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?

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

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

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

1 Like

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

See

2 Likes

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

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.