I am trying to connect to a rinkeby full node in ubuntu terminal and i have a node js app deployed trying to connect using web3 when consoling the nodejs app getting connection error
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.
at Object.InvalidConnection (/var/www/ethernode/node_modules/web3/lib/web3/errors.js:31:16)
at HttpProvider.send (/var/www/ethernode/node_modules/web3/lib/web3/httpprovider.js:93:18)
at RequestManager.send (/var/www/ethernode/node_modules/web3/lib/web3/requestmanager.js:58:32)
at Eth.get [as coinbase] (/var/www/ethernode/node_modules/web3/lib/web3/property.js:107:62)
at app.get (/var/www/ethernode/app.js:37:29)
at Layer.handle [as handle_request] (/var/www/ethernode/node_modules/express/lib/router/layer.js:95:5)
at next (/var/www/ethernode/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/www/ethernode/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/www/ethernode/node_modules/express/lib/router/layer.js:95:5)
at /var/www/ethernode/node_modules/express/lib/router/index.js:281:22
some one in stack overflow told to change the localhost to public Ip address , and that also didn't work , some one tell me what is happening here ?
Best Answer
Run the geth node on rinkeby testnet:
make sure it's synced up:
connect provider: