Curl error 7 on vagrant using guzzle

2019-04-14 12:27发布

问题:

I've get an Curl error 7: Failed to connect to site1.local port 8000: Connection refused, when i call it from another local site (site2.local). Both sites run on the same Vagrant box.

When i replace the url to an url of an external site (eg. google.com), there is no problem in connecting.

Why does vagrant refuse a call from his own? I searched the problem, but couldn't find any solution to this.

Is there a way to call to another site on the same server using curl?

edit:

Vagrantfile:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  Homestead.configure(config, YAML::load(File.read(path + '/Homestead.yaml')))
end

Homestead.yaml

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: C:/Users/Robert/.ssh/id_rsa.pub

keys:
    - C:/Users/Robert/.ssh/id_rsa

folders:
    - map: A:/homestead/projects
      to: /home/vagrant/projects

sites:
    - map: site1.local
      to: /home/vagrant/projects/work/work-site-1/public
   - map: site2.local
      to: /home/vagrant/projects/work/work-site-2/public

回答1:

The 8000 and 8443 ports are only used when you want to access a site in vagrant from your local box (host machine). If you want to access a site within vagrant (guest machine) you should use the standard HTTP port (80), since no kind of mapping is needed.

I bet that's the issue.