[networking] How do I increase the RAM and set up host-only networking in Vagrant?

I would like to increase the RAM to at least 1 GB and I would like to configure “Host-Only” networking to use "199.188.44.20".

This is my Vagrantfile:

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

Vagrant::Config.run do |config|

    config.vm.customize ["modifyvm", :id, "--memory", 1024]

    config.vm.network :hostonly, "199.188.44.20"

    config.vm.define :web do |web_config|
        web_config.vm.box = "lucid32"
        web_config.vm.forward_port 80, 8080

        web_config.vm.provision :puppet do |puppet|
            puppet.manifests_path = "manifests"
            puppet.manifest_file = "lucid32.pp"
        end
    end

    config.vm.define :web2 do |web2_config| 
        web2_config.vm.box = "lucid32"
        web2_config.vm.forward_port 80, 8081

        web2_config.vm.provision :puppet do |puppet|
            puppet.manifests_path = "manifests"
            puppet.manifest_file = "myweb.pp"
        end
    end
end

However, when I run vagrant up I am getting:

The VM failed to remain in the "running" state while attempting to boot. This is normally cause by a misconfiguration or host system incompatibles. Please open the VirtualBox GUI and attempt to boot the virtual machine manually to get more informative error message

And, I am getting a connection refuse error when I try to log in to the VM.

This question is related to networking configuration vagrant

The answer is


You can easily increase your VM's RAM by modifying the memory property of config.vm.provider section in your vagrant file.

config.vm.provider "virtualbox" do |vb|
 vb.memory = "4096"
end

This allocates about 4GB of RAM to your VM. You can change this according to your requirement. For example, following setting would allocate 2GB of RAM to your VM.

config.vm.provider "virtualbox" do |vb|
 vb.memory = "2048"
end

Try removing the config.vm.customize ["modifyvm", :id, "--memory", 1024] in your file, and adding the above code.

For the network configuration, try modifying the config.vm.network :hostonly, "199.188.44.20" in your file toconfig.vm.network "private_network", ip: "199.188.44.20"


To increase the memory or CPU count when using Vagrant 2, add this to your Vagrantfile

Vagrant.configure("2") do |config|
    # usual vagrant config here

    config.vm.provider "virtualbox" do |v|
        v.memory = 1024
        v.cpus = 2
    end
end

Since Vagrant 1.1 customize option is getting VirtualBox-specific.

The modern way to do it is:

config.vm.provider :virtualbox do |vb|
  vb.customize ["modifyvm", :id, "--memory", "256"]
end

I could not get any of these answers to work. Here's what I ended up putting at the very top of my Vagrantfile, before the Vagrant::Config.run do block:

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]
  end
end

I noticed that the shortcut accessor style, "vb.memory = 1024", didn't seem to work.


Examples related to networking

Access HTTP response as string in Go Communication between multiple docker-compose projects Can't access 127.0.0.1 How do I delete virtual interface in Linux? ConnectivityManager getNetworkInfo(int) deprecated Bridged networking not working in Virtualbox under Windows 10 Difference between PACKETS and FRAMES How to communicate between Docker containers via "hostname" java.net.ConnectException: failed to connect to /192.168.253.3 (port 2468): connect failed: ECONNREFUSED (Connection refused) wget: unable to resolve host address `http'

Examples related to configuration

My eclipse won't open, i download the bundle pack it keeps saying error log Getting value from appsettings.json in .net core pgadmin4 : postgresql application server could not be contacted. ASP.NET Core configuration for .NET Core console application Turning off eslint rule for a specific file PHP Warning: Module already loaded in Unknown on line 0 How to read AppSettings values from a .json file in ASP.NET Core How to store Configuration file and read it using React Hadoop cluster setup - java.net.ConnectException: Connection refused Maven Jacoco Configuration - Exclude classes/packages from report not working

Examples related to vagrant

vagrant primary box defined but commands still run against all boxes Psql could not connect to server: No such file or directory, 5432 error? Failed to open/create the internal network Vagrant on Windows10 Is there a default password to connect to vagrant when using `homestead ssh` for the first time? vagrant login as root by default How can I kill whatever process is using port 8080 so that I can vagrant up? Using Laravel Homestead: 'no input file specified' Error when trying vagrant up Vagrant ssh authentication failure Vagrant error : Failed to mount folders in Linux guest