hashicorp/vagrant · error · Vagrant::Errors::MachineNotFound

The machine with the name '%{name}' was not found configured

Error message

The machine with the name '%{name}' was not found configured for
this Vagrant environment.

What it means

Raised by VagrantFile#machine_config when the requested machine name has no entry in `config.vm.defined_vms`, i.e. no `config.vm.define "<name>"` block matches. Vagrant looks machines up strictly by the keys defined in the Vagrantfile; there is no default fallback name. The check is a plain hash lookup on the exact (case-sensitive) name.

Source

Thrown at lib/vagrant/vagrantfile.rb:122

    #   - config_errors: list of errors, if any
    #   - config_warnings: list of warnings, if any
    #   - provider_cls: class of the provider backing the machine
    #   - provider_options: options for the provider
    #
    # @param [Symbol] name Name of the machine.
    # @param [Symbol] provider The provider the machine should
    #   be backed by (required for provider overrides).
    # @param [BoxCollection] boxes BoxCollection to look up the
    #   box Vagrantfile.
    # @param [Pathname] data_path Machine data path
    # @return [Hash<Symbol, Object>] Various configuration parameters for a
    #   machine. See the main documentation body for more info.
    def machine_config(name, provider, boxes, data_path=nil, validate_provider=true)
      keys = @keys.dup

      sub_machine = @config.vm.defined_vms[name]
      if !sub_machine
        raise Errors::MachineNotFound,
          name: name, provider: provider
      end

      provider_plugin  = nil
      provider_cls     = nil
      provider_options = {}
      box_formats      = nil
      if provider != nil
        provider_plugin  = Vagrant.plugin("2").manager.providers[provider]
        if !provider_plugin && validate_provider
          providers  = Vagrant.plugin("2").manager.providers.to_hash.keys
          if providers
            providers_str = providers.join(', ')
          else
            providers_str = "N/A"
          end

          if providers.include? provider.downcase

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run `vagrant status` to list the machines actually defined in this environment
  2. Fix the name/case - names are exact strings from `config.vm.define`
  3. Make sure you are in the directory that contains the Vagrantfile defining the machine
  4. If the define block is conditional, verify the condition actually evaluates truthily

Example fix

# before
vagrant ssh webb   # typo; only web and db are defined

# after
vagrant status      # lists: web, db
vagrant ssh web
Defensive patterns

Strategy: validation

Validate before calling

# bash: assert the machine exists before targeting it
vagrant status --machine-readable 2>/dev/null |
  awk -F, '$3 != "" {print $3}' | sort -u |
  grep -qx "$MACHINE" || { echo "no such machine: $MACHINE (defined: $(vagrant status -s)"; exit 1; }

Type guard

# Ruby: narrow to defined machine names before calling machine APIs
def machine_defined?(env, name)
  env.vagrantfile.machine_names.include?(name.to_sym) # Vagrantfile#machine_names
end

Try / catch

begin
  machine = env.machine(name, :virtualbox)
rescue Vagrant::Errors::MachineNotFound
  warn "defined machines: #{env.vagrantfile.machine_names.join(', ')}"
  raise
end

Prevention

When it happens

Trigger: Any command or API call that targets a named machine - `vagrant up <name>`, `vagrant ssh <name>`, `vagrant destroy <name>`, or Environment#machine / VagrantFile#machine_config - where `@config.vm.defined_vms[name]` is nil.

Common situations: Typo or wrong casing in the machine name; running the command in the wrong directory (different or no Vagrantfile); a define block inside an `if` or loop that did not execute; copying a command from another project's docs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/516291354c6f1b77. Report an issue: GitHub.