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

An active machine was found with a different provider. Vagra

Error message

An active machine was found with a different provider. Vagrant
currently allows each machine to be brought up with only a single
provider at a time. A future version will remove this limitation.
Until then, please destroy the existing machine to up with a new
provider.

Machine name: %{name}
Active provider: %{active_provider}
Requested provider: %{requested_provider}

What it means

with_target_vms found the named machine already active in the machine index under one provider while the command explicitly requested a different provider via --provider (lib/vagrant/plugin/v2/command.rb:163). Vagrant enforces one provider per machine at a time, so it refuses to create a second instance; the message names the machine, the active provider, and the requested one.

Source

Thrown at lib/vagrant/plugin/v2/command.rb:163

              rescue Vagrant::Errors::EnvironmentNonExistentCWD
                # This means that this environment working directory
                # no longer exists, so delete this entry.
                entry = @env.machine_index.get(name.to_s)
                @env.machine_index.delete(entry) if entry
                raise
              end

              next env.machine(entry.name.to_sym, entry.provider.to_sym)
            end

            active_machines.each do |active_name, active_provider|
              if name == active_name
                # We found an active machine with the same name

                if provider_to_use && provider_to_use != active_provider
                  # We found an active machine with a provider that doesn't
                  # match the requested provider. Show an error.
                  raise Errors::ActiveMachineWithDifferentProvider,
                    name: active_name.to_s,
                    active_provider: active_provider.to_s,
                    requested_provider: provider_to_use.to_s
                else
                  # Use this provider and exit out of the loop. One of the
                  # invariants [for now] is that there shouldn't be machines
                  # with multiple providers.
                  @logger.info("Active machine found with name #{active_name}. " +
                               "Using provider: #{active_provider}")
                  provider_to_use = active_provider
                  break
                end
              end
            end

            # Use the default provider if nothing else
            provider_to_use ||= @env.default_provider(machine: name)

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. If you truly want the other provider: `vagrant destroy <name>` (or destroy the global-status entry), then `vagrant up <name> --provider=<new>`
  2. If you just want it running: drop the --provider flag and let Vagrant reuse the active provider
  3. If the machine was already destroyed but the error persists, the index entry is stale — run `vagrant global-status --prune` or destroy the listed entry to clear it

Example fix

# before (web is active under virtualbox)
vagrant up web --provider=vmware_desktop

# after
vagrant destroy web
vagrant up web --provider=vmware_desktop
Defensive patterns

Strategy: validation

Validate before calling

entry = env.active_machines.find { |n, _| n == name.to_sym }
if entry && provider && entry[1] != provider
  abort "#{name} is active under #{entry[1]}; destroy it first or omit --provider"
end

Try / catch

begin
  command.with_target_vms([name], provider: provider) { |m| operate(m) }
rescue Vagrant::Errors::ActiveMachineWithDifferentProvider => e
  d = e.extra_data # {name:, active_provider:, requested_provider:}
  warn "#{d[:name]} runs under #{d[:active_provider]}; destroy it or drop --provider"
end

Prevention

When it happens

Trigger: `vagrant up myvm --provider=vmware_desktop` when myvm is currently up (or indexed) under virtualbox; same for hyperv <-> virtualbox switches; also when a CI script hardcodes --provider against an already-created machine.

Common situations: Migrating a machine between providers without destroying first; leftover index entry after a crashed or interrupted destroy; teammates sharing a project root with different provider defaults.

Related errors


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