peterd
November 23, 2020, 8:50pm
1
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?
JasonW
November 23, 2020, 9:24pm
2
are goal commands working on the node? Ie goal node status -d data
peterd
November 23, 2020, 9:27pm
3
Yes the ‘goal node status -d data’ command is working.
JasonW
November 23, 2020, 9:29pm
4
any chance you can run that node code on the server to make sure that is working.
1 Like
fabrice
November 23, 2020, 9:57pm
5
Have you changed the EndpointAddress in config.json to allow connections from 0.0.0.0 instead of just localhost?
See
Algorand Developer Docs, SDKs, REST APIs, CLI tools, ecosystem projects, metrics dashboard and sample code, how-tos, and news from the Algorand developer community
Have you changed $ALGORAND_DATA/config.json (for algod) and $ALGORAND_DATA/kmd/kmd-v0.5/kmd_config.json (for kmd) to allow connections from any IP? By default, it only allows connections from localhost.
Concretely, have you set EndpointAddress to 0.0.0.0:8080 for algod and address to 0.0.0.0:7833 for kmd?
See:
3 Likes
peterd
November 23, 2020, 10:47pm
6
No I had not done this step. This fixed my issue, thanks for your help!
peterd
November 23, 2020, 10:51pm
7
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.