Can't connect to Vagrant using HeidiSQL: "Can't connect to MySQL server on 'localhost'" Can't connect to Vagrant using HeidiSQL: "Can't connect to MySQL server on 'localhost'" linux linux

Can't connect to Vagrant using HeidiSQL: "Can't connect to MySQL server on 'localhost'"


One thing I overlooked is that "local port" under the SSH Tunnel tab is also required. To wrap it all together, there's three key ports to set.

If your Vagrantfile looks kind of like this:

Vagrant.configure("2") do |config|    config.vm.network "forwarded_port", guest: 3306, host: 3310    config.vm.network "private_network", ip: "192.168.100.11"end

and Vagrant auto-forwards the SSH port (22) to, say 2222 (you can check this by vagrant ssh-config, then the HeidiSQL config should be as follows:

Red brackets highlight fields to change

As new Vagrant versions use a custom-generated SSH key, you will need that instead of the vagrant/vagrant user/pw combination. The keys can be found in project location\.vagrant\machines\default\virtualbox.

This is as of HeidiSQL 9.4.0.5130 (64 Bit) on Windows 10.


This seems to be an issue with the version of HeidiSQL I was using. Upgrading to HeidiSQL 9.1 allowed me connect.


I still experience this issue in HeidiSQL 9.3. I've found that suspending and reloading the vagrant box can make it go away.