Using the following installation on AWS EC2 Server Ubuntu 20.04

npm install --save-dev [email protected]

using the following command:

npm hardhat node

getting the (following) response ( warning sign: which is not going to connect for a remote client to AWS localhost )

enter image description here producing the following error from metamask trying to touch my network:

enter image description here

I have tried a number of variations in the hardhat.config.js including :

networks: { 
    localhost: { 
        url: "http://ec2-44-242-170-11.us-west-2.compute.amazonaws.com:8545"
    hardhat: {
        chainId: 31337

I have tried 1337, 2710 as chainID, examining Hardhat console to find the chainID as well as variations of the hardhat.config.js as well as different browsers ( no problems connecting with ganache on this instance ) as well as adding extra parameters in the "npm hardhat node" command. I can connect to my instance if I run react.js so there are no issues with security groups either I can also connect to truffle in very similar fashion (using dns in config and command line). Any insight would help!

1 Answer 1


The networks object configures Harhat of what network configuration to use when you apply the --network switch to your commands and as configuration for ethers/hardhat providers. It does not affect the JSON-RPC, WebSocket server configuration, and the network interfaces the local hardhat node binds to.

By default, the hardhat local node server only binds to the local loopback interface of, which is only available from within the host (the same machine) and not accessible on local/remote networks. It does not bind to network interfaces accessible outside the localhost loopback interface.

The way to change that behavior is to use the --hostname switch: enter image description here


npx hardhat node --hostname <YOUR_INTERNAL_IP>

If you wanted the node to listen on all available interfaces, you could do the following:

npx hardhat node --hostname

In addition, consider adding this command to your package.json file: enter image description here

Run it with: npm run node enter image description here

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.