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 plain machine name given to a v2 command resolved to no machine — get_machine.call(name.to_sym) returned nothing and the guard at lib/vagrant/plugin/v2/command.rb:208 raised. A name resolves only if it is defined in the local Vagrantfile's config.vm.define blocks or exists as an active/index machine; otherwise it is 'not found'.
Source
Thrown at lib/vagrant/plugin/v2/command.rb:208
if pattern = name[/^\/(.+?)\/$/, 1]
@logger.debug("Finding machines that match regex: #{pattern}")
# This is a regular expression name, so we convert to a regular
# expression and allow that sort of matching.
regex = Regexp.new(pattern)
@env.machine_names.each do |machine_name|
if machine_name =~ regex
machines << get_machine.call(machine_name)
end
end
raise Errors::VMNoMatchError if machines.empty?
else
# String name, just look for a specific VM
@logger.debug("Finding machine that match name: #{name}")
machines << get_machine.call(name.to_sym)
raise Errors::VMNotFoundError, name: name if !machines[0]
end
end
else
# No name was given, so we return every VM in the order
# configured.
@logger.debug("Loading all machines...")
machines = @env.machine_names.map do |machine_name|
get_machine.call(machine_name)
end
end
@logger.debug("have machine list to process")
# Make sure we're only working with one VM if single target
if options[:single_target] && machines.length != 1
@logger.debug("Using primary machine since single target")
primary_name = @env.primary_machine_name
raise Errors::MultiVMTargetRequired if !primary_nameView on GitHub (pinned to 35f3160f4a)
Solutions
- Run `vagrant status` to list the machine names valid for this environment
- For non-local machines, get a fresh ID from `vagrant global-status` and use that
- If the machine should exist locally, add the missing config.vm.define block to the Vagrantfile
Defensive patterns
Strategy: validation
Validate before calling
valid = env.machine_names.map(&:to_s)
known_ids = env.machine_index.to_a.map { |e| e.name.to_s }
abort "unknown machine '#{name}'" unless valid.include?(name) || known_ids.include?(name) Prevention
- List valid names with `vagrant status` before targeting machines in scripts
- Use full current IDs from `vagrant global-status` for non-local machines
- Update scripts whenever config.vm.define names change
When it happens
Trigger: `vagrant ssh db` where the Vagrantfile defines only :web; using an expired global-status ID as if it were a name; a machine defined in a different project directory.
Common situations: Typos and case mismatches; commands copied from docs for a different Vagrantfile; renaming vm.define blocks without updating wrapper scripts.
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
- No virtual machines matched the regular expression given.
- This command requires a specific VM name to target in a mult
- A VM by the name of %{name} was not found.
- An invalid option was specified. The help for this command i
- The box you requested to be removed could not be found. No b
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/ffcdf6cdc8c6494e.
Report an issue: GitHub.