Confusion of running sdk on different machines

Hey guys.

I have run my private or test chain in a virtual machine, but when I want to run my smart contract on the host using the node address and token (using sdk), it says that the connection cannot be established, the results are as follow.
Address: 6WUADPYI2OSZS4NPJQWCVIJ3TGVOQP6SDNPLIYBMJJW4QCM4TPDTS33BO4
Address: U2VFKT5OXW3HVDBOWNVZFPGY3IMKFCI7N6RN4IIESHQTITLITPT3JJPXCM
Issue with compile: Post “http://127.0.0.1:8080/v2/teal/compile”: dial tcp 127.0.0.1:8080: connectex: No connection could be made because the target machine actively refused it.
Issue with compile: Post “http://127.0.0.1:8080/v2/teal/compile”: dial tcp 127.0.0.1:8080: connectex: No connection could be made because the target machine actively refused it.

What’s going on here. Do I need to set anything in the virtual machine for the node? Or am I using the wrong port?

  1. Are you sure 127.0.0.1:8080 is routed to the VM? Usually VMs have their own IP that is not localhost (although it is possible you configured your virtualization software differently).
  2. If it indeed goes to the VM, you may still need to allow connections from 0.0.0.0:8080 in the config.json of the node. Parameter EndpointAddress. Node Configuration Settings - Algorand Developer Portal
  3. You may have a firewall at several levels: the VM may have a firewall, the host may have a firewall (very unlikely though), the virtualization software may have a firewall.

Thank you very much, fabrice!
Following your method, I have successfully set it up.