I created a Vagrantfile for a VM, the provider is VirtualBox. The Vagrantfile exposes some ports in this way:
if (MINDSDB_APIS.include? 'mysql') and PORT_MYSQL.to_i > 0
config.vm.network 'forwarded_port', guest: 47335, host: PORT_MYSQL
end
if (MINDSDB_APIS.include? 'http') and PORT_HTTP.to_i > 0
config.vm.network 'forwarded_port', guest: 47334, host: PORT_HTTP
end
(those ports are not standard but they’re correct, the reason would be a bit long to explain here)
Inside the VM, everything seems to work correctly: I can connect to 47335 with a MySQL client and get results from 47334 with curl.
Outside of the VM, the MySQL client and curl don’t seem to connect:
# mycli -hlocalhost -p3306
(2003, "Can't connect to MySQL server on 'localhost' ([Errno 61] Connection refused)")
# curl -g http://127.0.0.1:47334/api/predictors/
curl: (7) Failed to connect to 127.0.0.1 port 47334: Connection refused
Before you think that things vaguely make sense, I want to let you know that netcat communicates as expected. If I shutdown the servers in the VM and start nc -l 47334
(or 47335), I’m able to run nc -v 127.0.0.1 47334
(or 47335) in the host system, and see the output appearing in the VM’s shell as expected.
I tried running Apache and another version of MySQL in the VM, nothing changes. At this point, I don’t even know if the problem lies in my Vagrantfile, in Vagrant, or in VirtualBox. Anyone can help?