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

mikebronner's avatar

How to make Homestead self-aware? (reference web site from within)

So, on our dev machine we have set out hosts file to reference all our local sites, like 127.0.0.1 mysite.dev.

How do I set up Homestead to recognize the sites it is hosting? Obviously the /etc/hosts file should be updated, but is there an automated way of doing this from the Homestead.yaml file?

Here's what I'm doing: I'm using CURL to connect to another page on the site to post data using a fully qualified URL. However, I'm getting the following response:

Failed to connect to mysite.dev port 8000: Connection refused
0 likes
2 replies
austenc's avatar

You generally define a site(s) in your Homestead.yaml and then only need to update the host file on the host machine.. then go to mysite.dev:8000. Site config will be stored in /etc/nginx/sites-available/mysite.dev. Laravel docs on daily usage may also help.

Apologies if I misunderstood your question..

1 like
mikebronner's avatar
mikebronner
OP
Best Answer
Level 16

I found the problem: it wasn't that Homestead didn't know about the domain, it sees that just fine, like you said. However, it doesn't know about port 8000 internally, so I had to override that using curl_setopt($ch, CURLOPT_PORT, 80);. Now it works!

Please or to participate in this conversation.