Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mpjraaij's avatar

Use local localhost instead of vagrant localhost in Homestead

I have my mongodb and mysql running on my local machine. Instead of using the vagrant database I want to use these.

However if I have my DB_HOST in the .env file obviously it connects to the localhost of vagrant.

How can I make the database connect to localhost / 127.0.01 on my local Mac OS X?

Thanks!

Maarten

0 likes
2 replies
martinbean's avatar

@mpjraaij You really shouldn’t be trying to access a database on your local machine, otherwise there’s no point running your application in a VM.

The idea of a VM is some one should be able to clone the repository, boot the VM, and have all the services they need to run the application within that VM (i.e. Mongo).

mpjraaij's avatar

Thanks Martin. I already figured out why it was failing what I wanted to establish. I was using vagrant destroy instead of vagrant halt. Not really smart!

Please or to participate in this conversation.