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

A VM by the name of %{name} was not found.

Error message

A VM by the name of %{name} was not found.

What it means

A v1 command was given a plain (non-regex) VM name that does not exist in the current environment: @env.vms[name.to_sym] returned nil and the guard at lib/vagrant/plugin/v1/command.rb:96 raised. Valid names come from the `config.vm.define :name` entries in the Vagrantfile (or the implicit `:default` for single-machine projects). Name lookup is case-sensitive.

Source

Thrown at lib/vagrant/plugin/v1/command.rb:96

          # First determine the proper array of VMs.
          vms = []
          if names.length > 0
            names.each do |name|
              if pattern = name[/^\/(.+?)\/$/, 1]
                # This is a regular expression name, so we convert to a regular
                # expression and allow that sort of matching.
                regex = Regexp.new(pattern)

                @env.vms.each do |name, vm|
                  vms << vm if name =~ regex
                end

                raise Errors::VMNoMatchError if vms.empty?
              else
                # String name, just look for a specific VM
                vms << @env.vms[name.to_sym]
                raise Errors::VMNotFoundError, name: name if !vms[0]
              end
            end
          else
            vms = @env.vms_ordered
          end

          # Make sure we're only working with one VM if single target
          if options[:single_target] && vms.length != 1
            vm = @env.primary_vm
            raise Errors::MultiVMTargetRequired if !vm
            vms = [vm]
          end

          # If we asked for reversed ordering, then reverse it
          vms.reverse! if options[:reverse]

          # Go through each VM and yield it!
          vms.each do |old_vm|

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run `vagrant status` to list the valid machine names for this environment
  2. Correct the name, watching case sensitivity
  3. If the machine should exist, add or fix its config.vm.define block in the Vagrantfile
Defensive patterns

Strategy: validation

Validate before calling

valid = env.vms.keys.map(&:to_s)
abort "unknown VM '#{name}'; valid names: #{valid.join(', ')}" unless valid.include?(name)

Prevention

When it happens

Trigger: `vagrant <cmd> web` where the Vagrantfile defines only :default or machines named differently; case mismatches (Web vs web); a name defined in a different project's Vagrantfile.

Common situations: Typos; commands copied from team chat or tutorials written for a different Vagrantfile; renaming a vm.define block without updating scripts that reference the old name.

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/0356247c4dcf4978. Report an issue: GitHub.