Think of your VM like a completely different machine. It has another IP for example.
127.0.0.1 accesses localhost and therefore your host machine.
So how do you fix this?
You need to connect to your VM with the correct IP. Go into your VM and run the command ifconfig.
A lot of stuff gets returned. You will surely recognice the correct IP when you see it. ...