Perspective
Perspective

Reputation: 632

Point Vagrant to a Local API

Hey guys I have two vagrant machines running, one is the app code base and the other is the api code base for the app. I want to be able to do a curl call from my app machine to the api machine.

On my computer I can call both because I have them in my etc/hosts file, but what do I need to do to successfully request from vagrant to vagrant.

I tried to go into my app vagrant machine's etc/hosts and add the domain with the 127.0.0.1 but no cigar.

Upvotes: 0

Views: 224

Answers (1)

Perspective
Perspective

Reputation: 632

So it turns out that Vagrant makes your guest machine's ip to 10.0.2.2. So what I did on my App code base vagrant machine. I edited the /etc/hosts to;

10.0.2.2 api.local.com

previously I tried 127.0.0.1, and that didn't work, so I just checked the apache access logs saw the ip and gave that a whirl. and that worked.

On my local machine I have; 127.0.0.1 api.local.com

I hope this helps.

Upvotes: 1

Related Questions