vagrant destroy with libvirt leaves stale port forwarding around
Author: lindesCreated Aug 12, 2026Updated Aug 12, 2026
Labelswaiting-intake
Debug output
I'm not sure you'll need them, as I hope I've provided sufficient information here, but in case you do, I've uploaded the debug files along with some related content here (attempting to paste into gist seems to have overloaded my browser's brain), with contents of several things:
- output (and error) of various vagrant commands, in the
?a-*(where?is 0-4, and*is the command that was run) files, as per the filenames, but with--debugappended. - output of
ps -ft $(tty) wwwfor each run, in?b-ps-after-?a.out, for each of the above - abbreviated output of
vagrant ssh -c "ip addr"in 4c-ip-addr-after-4a.out - the Vagrantfile (also below)
- the URL for a stack-overflow question mentioned (because copy/paste is still unhappy after the gist thing).
- partial output of an strace of vagrant up
- output of
vagrant --version
Expected behavior
- When running
vagrant destroy(orvagrant destroy -f), thesshprocesses that are used to forward ports should be killed, as it seems to be withvagrant halt. - Later, I expect new invocations of
vagrant upto have ports properly forwarded. - If that's not possible, I would expect to see an error generated.
Actual behavior
vagrant upcreates ansshprocess that seems to fork itself, andvagrant haltandvagrant destroyboth kill the parent of these two processes, but for whatever reason, whenvagrant destroydoes so (perhaps using a different signal?), the childsshprocess is not killed, thus locking in a forwarder that ends up having a stale IP address, and- not getting re-started in subsequent
vagrant up, because - while an attempt is made to launch a new
sshto forward ports, it silently (from a vagrant user's perspective, and even per the--debuglogs) fails... though runningvagrant upunderstrace -f -s 4096 ...shows thatbind()is gettingEADDRINUSE, because the old process is still around.
Reproduction information
Vagrant version
Vagrant 2.2.19 -- sorry it's not the latest; I'm hoping this is still relevant -- I found it in also existing in a StackOverflow answer from some years ago that hadn't been resolved, so... guessing it's a lingering bug. Unfortunately, I'm hitting this on a system where upgrading is infeasible currently.
Host operating system
Ubuntu 22.04.3 LTS
Guest operating system
Debian 13.5 trixie (debian/trixie64, libvirt, 13.20260519.1)
Steps to reproduce
vagrant upvagrant destroy -fvagrant up
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "debian/trixie64"
config.nfs.verify_installed = false
config.vm.network "forwarded_port", guest: 80, host: 8080
end
Source: hashicorp/vagrant