Saving a Vagrant Box/Not losing work

Hello,
I recently set up a Trellis/Bedrock/Sage environment. I like it so far but have been running into the issue that if I step away from my computer, I can’t reconnect to my local production environment and have to start up my wordpress install from scratch. Is there a way to “save” a vagrant box so I can close my computer and not have to vagrant destory, then vagrant up each time?

Thanks,

There must be something amiss, because the behavior you’re describing certainly isn’t intended. Vagrant boxes should persist naturally.

Can you give us a few more details, i.e. what sort error messages you’re seeing, a more detailed description of your setup, etc? You might start with:

  1. What error do you get when you find yourself unable to connect to your VM?
  2. Where does that error appear (i.e. is it a command line message; a 404 page in your browser; a filesystem error, etc)?
  3. What is your develompent environment like (i.e. are you on a Mac, a PC, a Linux box; what version of PHP/Python/Ansible do you have)?
  4. Are you running any other VMs (you can see all the VMs your system is aware of by run vagrant global-status)?

I’ve run into somewhat similar issues that had to IP assignments: By default Trellis uses the same IP for every box it spins up, so you can sometimes accidentally end up with several boxes fighting over the same IP, or a hosts file with several domains pointing to one IP (or visa-versa).

1 Like

Thank you for your response. This has been driving me a little crazy. I usually get a timeout error or refuses to connect. So what you are saying that if my computer falls asleep or shutsdown, my vagrant box should continue?

a 404 page in your browser;

Mac.
php 7.2
Python 2.7.14
ansible 2.5.2
config file = None

Any information or recommendations would be helpful.

Thank You!

If your computer falls asleep or shuts down without you running vagrant halt or vagrant suspend your VM will shut down (sometimes forcefully, although generally that shouldn’t cause too many problems) and should retain any data (i.e. database records, etc) the same way a normal computer will generally not lose all its data when it shuts down. You would probably need to run vagrant up after restart/waking your computer, but you shouldn’t have to regularly destroy your VMs.

Here are a few things to try (please post any errors they throw):

  1. After your VM stops responding, run vagrant up. If your machine has stopped, this should start it.
  2. Run vagrant reload. This will restart your machine, which may help if it has ended up in an odd state.
  3. After your VM stops responding, rung vagrant status. This should tell you if your machine is reporting itself to be in a good state.
  4. Run vagrant global-status. This will show you the status of all machines Vagrant is aware of. If you have any other running machines, shut them down before trying to run your machine again.
  5. After your VM stops responding, run vagrant ssh and see if it succeeds. If it does succeed, check the status of nginx and PHP on your VM, and check out your VM’s error logs.
2 Likes

Could this be the nginx restart problem recently fixed in Trellis?

1 Like

Are you talking about this issue?

Hi, thanks for joining the conversation. The problem happened again today. I vagrant ssh into the setup, do you know where I can see issues?

Thanks again, I really appreciate the help.

Yeah, the fix is merged but if @mkSage cloned last week it might be the problem they’re having. It presents as the site not coming back up after a reboot and if you don’t know how to manually restart nginx I can definitely understand having to rebuild the vagrant box every time.

Can you guys recommend a course of action?

Apply this change to your Trellis installation:

…and make sure to re-provision :slight_smile:

2 Likes

Thank you for your help, vagrant seem to be working. I really appreciate your time.

Thank you for your help! I really appreciate it!