Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putty fails to connect to Vagrant

Tags:

vagrant

I am trying to connect to the Vagrant server using putty with IP:127.0.0.1 and port:2222. Yesterday i login successfully using username:vagrant and pass:vagrant. Today, unforunately this is what i received is a dialog box:"PuTTy fatal error:network error:Connection refused". Any ideas/suggestions about how to fix that

like image 545
user3718905 Avatar asked Oct 23 '25 14:10

user3718905


1 Answers

You may want to try configuring a static IP address for your VM in your Vagrantfile. Through past experience, I've found this to be a more stable way of connecting to your VM via SSH/SCP/SFTP or similar.

To set a static IP address (e.g. in this case 192.168.50.10), you'd put the following in your VagrantFile:

# Create a private network, which allows host-only access to the VM
# using the Static IP 192.168.50.10
config.vm.network :private_network, ip: "192.168.50.10"

This is documented in more detail in the Vagrant Documentation on Private Networks.

Once you've configured a static IP (and rerun 'vagrant up' or 'vagrant reload'), you should be able to connect to your VM using Putty/SSH by using that Static IP (192.168.50.10) and port 22.

like image 182
Tim Donohue Avatar answered Oct 26 '25 18:10

Tim Donohue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!