Can’t connect to the VM: Connection refused

You are here:
Estimated reading time: 1 min

Use Case

The VM is ready as shown by the screenshot below:

VM ready

Then you connect to the VM through SSH FROM ANOTHER terminal with the command

ssh -p 2222 vagrant@localhost

And you get the following error:

Connection refused

Cause

You didn’t configure the Network adapters correctly

Solution

Shutdown the VM.

In the settings of the VM, go to Network

Adapter 1 must be attached to NAT as shown in the screenshot below

VM settings Adapter 1

Adapter 2 must be attached to Bridged Adapter with the first item of the list selected

In my case en0 as shown below

VM settings Adapter 2

Once everything the Adapters are correctly defined, run the VM and try to connect again.

If you are on Windows,

Try to connect to the VM with Putty: https://marclamberti.com/blog/connect-ssh-using-putty/

The host should be 127.0.0.1 on port 2222

When you the prompt shows:

Putty prompt

Type:

vagrant

and the password is vagrant as well

Was this article helpful?
Dislike 0
Views: 205