Ping to Laravel Homestead is Fine but Web Connection Refused - laravel-5

I just set up a homestead on my Windows 10 machine. Everything looks fine but page is not loading. I am getting connection refused on my browser.
I have asked this on Laracasts with details
https://laracasts.com/discuss/channels/servers/ping-to-homestead-is-fine-but-connection-refused#reply=495171
I think it is a minor issue but don't know where and what to look for.
My Homestead.yaml file:
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: d:/DATA/SourceCodes/laravel
to: /home/vagrant/code
sites:
- map: myapp.test
to: /home/vagrant/code/myapp/public
databases:
- homestead

at many times I found that modern browsers refuses to connect to urls that is ending with some unknown extensions for security reasons, so maybe its the url.
add "myapp.test" to Homestead.yaml file > sites: -map: myapp.test.
make sure you did edit hosts added line192.168.10.10 myapp.test
another possibilities:
if you are using antivirus or any internet security program on your
host system: disable it for a while and test.
if you use proxy for your internet connection, add myapp.test as an exception or disable the proxy for a while

Seems to be a problem with nginx. Try to login to homestead with ssh and check if nginx is running. I had the same problem after upgrading Homestead when my nginx config file was throwing an error (check your config with nginx -t)

Related

Homestead cant access second site remotely

I have one site setup fine, but the second can't be accessed remotely:
My YAML:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: app.app
to: /home/vagrant/sites/app1/public
- map: app2.app
to: /home/vagrant/sites/app2/public
port: 8100
ports:
- host: 81
- guest: 8100
I can access the first site using my IP easily - http://192.168.0.5/ but the second one cannot share the same port, so I've added 81 -> 8100.
When I try to reprovision my homestead vagrant box it says:
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* Forwarded port definitions require a "host" and "guest" value
* Ports to forward must be 1 to 65535
* Ports to forward must be 1 to 65535
Any ideas?
The service xip.io can make short work of this. Here's how:
As an example, I have the following Homesite app setup, 'rentmanager.test'. This is the first application I provisioned on Homestead, so it's the default route. To access this from my local network, all I have to do is go to:
http://rentmanager.test.192.168.5.124.xip.io:8000
Where 'rentmanager.test.' is the name of my Laravel application on Homestead, '192.166.5.124.' is my IP address on the local network, 'xip.io:8000' is the redirect service domain and the needed port to access the app (8000) outside of the default routing that Homestead sets up.
Now, this works fine out of the box with the first site you provision, but what happens if we have more than one site? That requires a little more legwork. Let's assume we've got a second app called 'sitescanner.test' that we want to access. If I try to access the same URL above with the new app URL, you'll see I'm still served the first application! Let's resolve that as well.
First, you're going to need to add an additional rule to your hosts file. So, assuming our new app is called 'sitescanner.test':
# Vagrant Sites External Access
192.168.10.10 sitescanner.test.192.168.5.124.xip.io
Once that's in place then we have to update the provisioning scripts in Homestead to create the correct virtual host entries so Homestead knows how to route the request. To do that, we'll edit your Homestead.yaml. Under the 'sites:' directive:
- map: sitescanner.test
to: /home/vagrant/Code/sitescanner/public
- map: sitescanner.test.192.168.5.124.xip.io
to: /home/vagrant/Code/sitescanner/public
Once this is complete, simply 'vagrant halt' (if it's already running), then 'vagrant up --provision' and you should be able to access your site from
http://sitescanner.test.192.168.5.124.xip.io:8000
Anywhere on your network! Hope this helps.
While I'm thinking about it, there is a final consideration for this configuration:
You may want to set a static IP address on your host machine if possible. If you're being assigned a dynamic IP address via DHCP it's possible (and likely) for this configuration to eventually break if you're ever assigned a new IP.
According to the documentation found at https://laravel.com/docs/5.4/homestead
you don't need to specify ports when adding multiple sites
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: another.app
to: /home/vagrant/Code/another/public
then add the following to your hosts file
192.168.10.10 homestead.app
192.168.10.10 another.app
make sure to run vagrant reload --provision
I do not know which version of Laravel or Homestead you are using, but this is possible. With the Homestead versions documented for Laravel 5.6 or 5.7, you were 95% of the way to having this complete.
Instead of using port: 8100 in your sites configuration, you should have used port: 81.
Instead of guest and host, use send and to.
I used the exact same setup as you except for those two differences, and it works for me.
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: app.app
to: /home/vagrant/sites/app1/public
- map: app2.app
to: /home/vagrant/sites/app2/public
port: 81
ports:
- send: 8100
to: 81
You would then be able to access your app via http://app2.app:8100 if your hosts file has an entry for app2.app or via http://192.168.0.5:8100 if you aren't using the hosts file.

Homestead project runs only when used 127.0.0.1 in the hosts file

I am new to the Homestead and virtualbox/vagrant world. I went through some video tutorials on how to strat working with Homestead.
Everything went smoothly until the last step. It says we need to add the IP address mention in the Homestead.yaml file into the hosts file.
I did that, but it always gave me the following error:
This site can’t be reached
dev.test refused to connect.
Search Google for dev test 8000
ERR_CONNECTION_REFUSED
My hosts file looks something like this:
192.168.10.10 dev.test
But when I use 127.0.0.1 dev.test it works perfectly fine.
I don't know what's happening.
Even the official documentation says we should 192.168.10.10 dev.test in the /etc/hosts file.
Where am I going wrong??
Here's my Homestead.yaml file
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/laravel.pub
keys:
- ~/.ssh/laravel
folders:
- map: /var/www/Laravel
to: /home/vagrant/Laravel
sites:
- map: dev.test
to: /home/vagrant/Laravel/test/public
databases:
- homestead
Looks like I found my mistake.
I was trying to access my web app using port 8000 even after using 192.168.10.10 dev.test in the hosts file. I should have simply used dev.test in the browser to access the web app.
Silly Mistake.
I makes perfect sense to use dev.test:8000 in the browser if the hosts file reads 127.0.0.1 dev.test

Homestead Running, SSH Works, But HTTP Connections Time Out

I'm having an issue with a homestead configuration that was previously running correctly. After reading some bad advice online regarding a separate issue, I accidentally wiped out my homestead.yaml by re-running init.bat, and have recreated the homestead config from memory the best I can. Most everything seems to be working - I can start the box successfully, and I can connect via SSH. My web root is mapped to the box correctly, as I can see all my project files on the box where I chose to map them. When I try to access the site via http (through the name I've mapped it to), I get a timeout. I've ensured that my hosts file has the update from myapp.app to 192.168.10.10, the same IP as in my homestead.yaml file. I will note, however, that when I ping 192.168.10.10 from the terminal, I also get a timeout.
Here's my Homestead.yaml:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: C:/Users/MyUsername/.ssh/id_rsa.pub
keys:
- C:/Users/MyUsername/.ssh/id_rsa
folders:
- map: C:/Users/MyUsername/Projects/myapp_laravel
to: /home/vagrant/code/myapp
sites:
- map: myapp.app
to: /home/vagrant/code/myapp/public
databases:
- homestead
Here's my hosts file:
192.168.10.10 myapp.app
I'll also note that I can successfully access my app via: http://localhost:8000/
I have also restarted my host machine since updating the hosts file, and reprovisioned the box.
Restarting the host machine again solved this for me.

How to troubleshoot and enable folder synchronisation in Laravel Homestead?

I have followed instructions (https://laravel.com/docs/5.2/homestead) to set up laravel running in a Vagrant/Homestead box.
In the end, I should be able to the website from virtual machine by accessing homestead.app in browser on my host machine.
I´ve tried accessing in different ways, with and without specifying port 8000:
http://homestead.app - connection timeout
http://192.168.10.10 - connection timeout
http://localhost - connection timeout
http://127.0.0.1 - connection refused
After troubleshooting I have found that files are not synced to the virtual machine.
E:\homestead_local\Laravel\public\ contains index.php which I try to access. It is not synced to the VM.
I can´t find any error logs on server.
Also, on VM home/vagrant folder was empty after I did everything from instructions. I´m not sure if that was supposed to happen.
Instructions of what I did, keeping them short:
Installed Virtualbox 4.2 and Vagrant 1.8.1
Dowloaded vagrant box:
vagrant box add laravel/homestead
Installed Homestead 0.4.1
git clone https://github.com/laravel/homestead.git Homestead
Initialized homestead:
bash init.sh
Edited homestead.yaml file
Edited hosts file
Hosts file:
192.168.10.10 homestead.app
127.0.0.1 homestead.app
homestead.yaml file:
ip: "192.168.10.10"
memory: 768
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: E:\HSprojects
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
Questions
After running "vagrant up" my CMD shows this:
....
default: Mounting shared folders...
default: /vagrant => E:/Homestead
Why is it showing E:/Homestead and not E:/HSProjects?
Is sharing between folders bidirectional? I can't find a clear answer on this, but I assume they are.

Homestead 2.0 giving issues on Yosemite

I have this strange problem. Let me describe it:
The mapping on the .yaml doesn't work. forum.app will just open up a Google search.
The debug is set to true for local, yet, errors aren't presented in browser. They're logged though.
I am using Homestead 2.0, Laravel 4 (everything is latest) on a Yosemite (updated today). The code is here:
YAML file
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/aligajani/Dropbox/Work/Code
to: /home/vagrant/Code
sites:
- map: forum.app
to: /home/vagrant/Code/CommunityFT/forum/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
HOSTS file
#Added by XAMPP Control
127.0.0.1 Alis-MacBook-Pro.local
192.168.10.10 forum.app
In order to get forum.app to be a valid domain that works with Homestead, you'll need to point it to your local computer in your hosts file.
You can do this by opening up terminal, and typing vim /etc/hosts, then add the line:
127.0.0.1 forum.app
Your browser may fail to look up the forum.app domain too, so remember to try adding a forward slash teh first time you visit it, so forum.app/, this will prevent the browser trying to google it.
Errors not being presented to the browser may be something to do with this pull request:
https://github.com/laravel/homestead/pull/140
Which is an Nginx configuration issue.
Hope this helps!

Resources