Debugging and Common Issues
Debugging and Common Issues
I personally keep my Vagrant setup vanilla.
This way I'm less likely to face bugs and am dependency free. When I have an issue I know it's either my OS, Virtual Box, or Vagrant. There's nothing else it can be.
This makes my life easy, especially since all 3 of those are constantly updating. If you can, I'd advise you to do the same.
Fair warning here. It goes without saying, but I want to say it anyway. Before upgrading your OS, your VirtualBox, or your Vagrant setup, make sure you have backups of all your VM data if you can't afford to spin them back up.
There are ways to run multiple Vagrant machines at one time.
I never do this though and for the scope of what we're talking about I would advise you against it. You'll need to do some messing around to get it working if that interests you though.
You should get in the habit of trying to do a workflow like this:
- One Project per Vagrantfile
- Vagrantfile lives with the Git Repo
- Get used to hopping around projects via
If you're working with a crazy big database, file, or process, your virtual VM "box" could run out of memory and crash and burn just like a regular server. Usually this just requires a reload, but you can always allocate more resources to a specific setup.
For example if you remember from earlier:
config.vm.provider "virtualbox" do |v| v.memory = 4096 v.cpus = 4 end
Are you lost on what is running or not running? Did something go crazy and you can't figure it out?
I'd recommend these steps:
You can open VirtualBox and visualize which machines are running. Then, you can just manually delete them from there.
Run "vagrant global-status"
vagrant global-status will actually tell you every VM that is running. It will also let you kill VM's via an ID. Usually like this:
vagrant destroy abc123
Things stored in the server in memory or elsewhere, such as a database, are completely lost when you do
vagrant destroy. This is normal expected behavior.
They are not lost though before you do
vagrant suspend or
vagrant halt. This is okay, but I would advise you to have a plan for quickly backing up your databases in case
vagrant up doesn't work. This is rare, but it's not a good idea to store any important data in the VM for long periods of time.
For example, I had the power go out once while Vagrant was running. My computer powered off and for whatever reason I could not restore the vagrant machine. It was corrupted or something. The same goes for when powering down your computer. Pause the VM first!
I'm sure in time I could have gotten in and recovered info, but I was in a great position because I saved time by just deleting the VM and starting over from my backup quickly.
Some people's Microsoft Window machines have issues. This could simply because a setting is turned off!
If you're getting an issue try to things:
Make sure Virtualization is Turn On in Bios
In your Bios, virtualization could be turned off for performance or security reasons. You can check to make sure it is on.
Turn Off Hyper-V
Try this if it still isn't working. Windows Hyper-V must be disabled in
Control Panel =>
Program And Features =>
Turn Windows Features on or off.
This should solve any virtualization issues. You can read more here.