3

I'm running vagrant up and I'm facing an issue that it seemed to be this one at the beginning Vagrant stuck connection timeout retrying. I've tried all the solutions in there, I also did a vagrant destroy, but as soon as I do vagrant suspend, then the vagrant up command doesn't work, I have to quit and do vagrant reload to get the VM working. It's very annoying and frustrating.

I'm using vagrant homestead version 0.4.4 at the moment and a part of this issue everything works perfectly once the VM is started.

My current system is OSX El Captain.

Let me know if you need more details.

My Vagrantfile:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))

homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"

require File.expand_path(confDir + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

Command up output when error:

~/Projects/credentialsApi (feature/10)$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: A newer version of the box 'laravel/homestead' is available! You currently
==> default: have version '0.4.4'. The latest is version '0.5.0'. Run
==> default: `vagrant box update` to update.
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
~/Projects/credentialsApi (feature/10)$

vagrant ssh-config command output:

~/Projects/credentialsApi (development)$vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2204
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile "/Users/pabloleone/Projects/credentialsApi/.vagrant/machines/default/virtualbox/private_key"
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes
6
  • Can you paste your command, Vagrantfile content and the output? Prefix also your command with VAGRANT_LOG=debug and paste the relevant part.
    – kenorb
    Commented Aug 1, 2016 at 14:58
  • I ran this command vagrant up --debug and the output is huge I don't think is useful. Commented Aug 1, 2016 at 21:34
  • Could you paste the Connection timeout error? Between 'Booting VM' and the error it-self? What have you tried already from the other answers and what was the result?
    – kenorb
    Commented Aug 1, 2016 at 22:10
  • After vagrant reload is vagrant ssh works fine?
    – kenorb
    Commented Aug 1, 2016 at 22:12
  • I tried them all and yes, after an error, vagrant reload works. Commented Aug 3, 2016 at 18:39

2 Answers 2

1

I finally fixed the issue. It was due to versions. I just upgraded vagrant and the VM.

0

First of all, try to run vagrant with VAGRANT_LOG=debug variable to debug the issue.


If that won't help, while it's showing you timeout messages, in another terminal run: vagrant status to see whether the VM is running correctly or not. Or run VirtualBox directly from GUI and check the machine state.


If it's running, check whether SSH credentials are correct, by the following command:

vagrant ssh-config

in order to:

  • check the hostname and port (e.g. 127.0.0.1:2222),
  • your private key (IdentityFile).

Also try logging in to the VM manually by:

vagrant ssh

or by this command (change default to proper host from above ssh-config command):

vagrant ssh-config > vagrant-ssh && ssh -F vagrant-ssh default

Since it works for you after vagrant reload (so your virtualization support in BIOS is likely enabled), possibly that your SSH server is not started by default on resume due to some issues. You should then check the SSH logs by fixing it via vagrant reload && vagrant ssh and check whether the logs by:

sudo tail /var/log/secure

If that's the case, for workaround to check whether the SSH service is run, add the following line like:

config.vm.provision :shell, run: "always", path: "scripts/check_ssh_service.sh"

Similar issue: Apache doesn't start after Vagrant reload


Finally check the following list for possible solutions to the SSH timeout problem:

  • Make sure your firewall or antivirus is not blocking the program (which I doubt will happen often)
  • Give your vagrant machine some time for timeouts to happen. If you dont have a very fast PC / Mac, the VM will take while to boot into an SSH ready state, so timeouts will happen.
  • Therefore, first try to let vagrant timeout COMPLETELY before concluding that there is a fault.
  • If vagrant times out completely then increase the timeout limit in the vagrant file to a few min and try again.
  • If that still doesnt work, then try to clean boot your vagrant machine through the VirtualBox interface and enable the GUI of the machine beforehand. If the GUI doesn't show anything happening (ie. just blackscreen, no text) while it is booting, then your vagrant machine has got problems.
  • Destroy the entire machine through the VB interface and reinstall.
  • Delete the ubuntu image files in the Vagrant Images folder in the user folder and redownload and install.
  • Do you even have an intel processor that supports 64bit hardware virtualisation? Google it. If you do, make sure there is no setting in your Bios disabling this feature.
  • Disable hyper-v feature if you are running windows 7 or 8. Google how to disable.
  • Make sure you are running through an SSH enabled client. Use Git bash. Download: http://git-scm.com/downloads
  • Install a 32bit version of ubuntu like trusty32 or precise32. Just change the version in the vagrant file and reinstall vagrant in new directory.
  • Make sure you are using the latest vagrant and virtualbox versions.
  • Last resorts: Format your computer, reinstall windows and buy an intel core isomething processor.

Source: GitHub post by @dezinerdudes


See also: SSH Timeout - Cant connect via ssh no matter what

3
  • Thank you for the big response. I updated the question with vagrant ssh-config command output. I checked the SSH logs, and nothing, then I run the VM with debug key and wow! huge output, not very useful. The vagrant status during the error says VM running. The other help is for Ubuntu and I'm on a Mac. I did try some of them but still the issue. Commented Aug 11, 2016 at 22:20
  • @PabloEzequielLeone The ports doesn't match: 2222 != 2204, you should investigate from where the incorrect port is coming from. Are you overriding anything vagrant-related in ~/.ssh/config or something?
    – kenorb
    Commented Aug 11, 2016 at 22:25
  • I did change the port to make them match, but still the issue. I also set the login with credentials without luck. I'm investigating Docker, Vagrant never worked correctly for me! Commented Aug 15, 2016 at 12:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.