Use Case
The VM is ready as shown by the screenshot below:

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:

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

Adapter 2 must be attached to Bridged Adapter with the first item of the list selected
In my case en0 as shown below

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:

Type:
vagrant
and the password is vagrant as well