Sushant Kumar
Sushant Kumar

Reputation: 455

How to run ganache-cli from Vagrant box?

I am running ganache-cli in a Vagrant box and trying to connect Metamask (Google Chrome) to it. But Metamask fails to connect to it. It connects if ganache-cli runs on the host machine. This is my Vagrant file

Vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.hostname = 'ethereum'
  config.vm.box = "ubuntu/bionic64"
  config.vm.provision :shell, path: "setup_dev_env.sh"
  config.vm.box_check_update = false

  config.vm.network "forwarded_port", guest: 3000, host: 3000, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8545, host: 8545, host_ip: "127.0.0.1"

  config.vm.synced_folder "SOME_PATH", "/home/vagrant/code"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "4096"
  end
end

Contents of setup_dev_env.sh

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install -y --allow-unauthenticated python3-pip mypy build-essential ethereum npm

sudo npm install -g ganache-cli
sudo apt-get update

Upvotes: 2

Views: 376

Answers (1)

Sushant Kumar
Sushant Kumar

Reputation: 455

Start ganache-cli with ganache-cli --host 0.0.0.0 and in Metamask enter details for Custom RPC in New RPC URL as http://0.0.0.0:8545

Upvotes: 2

Related Questions