Homestead Running, SSH Works, But HTTP Connections Time Out - laravel

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.

Related

Ping to Laravel Homestead is Fine but Web Connection Refused

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)

Laravel Homestead No input file specified

at the moment I am having a real nightmare trying to get Laravel Homestead to work. Usually when I have had this issue on my work machine I simply run vagrant provision however on my personal machine when I run vagrant provision nothing really happens it just hangs for a few seconds and then it is ready for another command.
Here is my setup Homestead.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: helloworld.app
to: /home/vagrant/Projects/HelloWorld/public
databases:
- homestead
My host file:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.10.10 helloworld.app
When I run vagrant up I get no errors either. I just get No input file specified. when I visit the URL in my browser.
Has anybody had this issue before?
Thanks, Nick
Looks like there is a line break after the sites: parameter. If thats true, get rid of that and run vagrant provision again.
Make your app/storage writeable by your homestead user.
I do not know if this is the case or not but if you are starting / stoping VM via the GUI, it may behave differently. Using vagrant <command> is always better for things like halt etc.
Update:
Make sure nginx config in your VM mirrors what you have on your yaml config file for homestead. I mean the public is also pointed in the nginx configs so check files under etc/ngnx/sites-available/ and make sure root points to where it is supposed to.
Update app/storage permissions with chmod -R 777 app/storage
Try running homestead up --provision it is homestead provision not vagrant.
You can find more information here some of the tutorial vids might require a subscription but I know some stuff is free there. Just in case it might help.

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.

Vagrant Laravel new project set up

I am now ready to start a new project with Laravel using Vagrant. My initial project worked fine but I can't seem to get the new project to show in the browser with its unique name loginauth.app.
My very first app was called PaulsApp and if I typed paulsapp.app in the browser the laravel started page showed fine.
I followed the instructions to create a new project using composer create project in my VM in the same directory as my first app. I can see this in both the local and on the VM.
Next I updated the homestead.yaml file to include the new sitemap and run vagrant provision to let the VM know of the updates.
I believe I must be overlooking something as my .yaml file has the map as homestead.app but that does not work only paulsapp.app which is in my etc/hosts file.
Please could somebody explain how the .yaml file and the hosts file are interacting. If I completely remove the mapping to PaulsApp in the yaml file, paulsapp.app in the browser still shows up the correct page.. as such I am a tad confused. I thought one simply added a mapping to the yaml and then could access that mapping through the browser. I want to type loginauth.app in the browser and have it point to the index file in the public directory of /home/vagrant/code/loginauth/ thanks.
homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
sites:
- map: homestead.app
to: /home/vagrant/code/PaulsApp/public
- map: loginauth.app
to: /home/vagrant/code/loginauth/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.10.10 Paulsapp.app
#127.0.0.1 PaulsApp.dev
OK so thanks to some help from the guys over at #laravel irc channel..
I needed to add the correct line to the hosts file. I tried 192.168.10.10 loginauth.app but got no joy so I used 127.0.0.1 loginauth.app.
Then the key was to vagrant halt the VM, Vagrant UP it again then vagrant provision it so the VM could see the changes.
Now loginauth.app:8000/ brings up the page I was hoping for...

How to setup Laravel Homestead server to run locally without being on a network/internet?

Previously, I manually setup my own VM on VirtualBox and configured it so it would also work when I'm coding offline (no internet/not connected to a router). I did this using settings in the VirtualBox GUI and also in Apache on the VM.
Now I'm interested in learning nginx and I've decided to try and use Laravel's Homestead. The tutorials I'm looking at seem to have the assumption I will be accessing the Homestead VM across the network (even though of course it's on the same PC). What do I need to do to ensure the VM will be accessible when I'm offline (like when I'm coding on a plane or train)? I'd like to still be able to have access to the internet from the VM whenever I do get back on WiFi (ie. for apt-get, etc.).
(note: My host machine is running Windows 7 64-bit)
Download and install fresh copies of Vagrant and Virtualbox.
https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2.msi
http://dlc-cdn.sun.com/virtualbox/4.3.22/VirtualBox-4.3.22-98236-Win.exe
Also download laravel/homestead manually
https://vagrantcloud.com/laravel/boxes/homestead/versions/0.2.2/providers/virtualbox.box
to my downloads folder C:\Downloads\homestead-0-2-2.box
After Installing Virtualbox and Vagrant. Installed laravel/homestead by running the following command in git bash (you can download git bash here: http://git-scm.com/downloads).
vagrant box add laravel/homestead /c/downloads/homestead-0-2-2.box
Run this command inside C:\users\yourusername
git clone https://github.com/laravel/homestead.git Homestead
NB: This will create this folder: C:\Users\yourusername\Homestead
With some files.
Still in Git bash, cd into C:\Users\yourusername\Homestead and run this command:
bash init.sh
NB: this will create a folder C:\Users\yourusername\.homestead that contains Homestead.yaml and some other files
Then Generate an SSH key which you will need when you want to login to your VM by running this command:
ssh-keygen -t rsa -C "youremailaddress#youremail.com"
NB: This will ask some question simply hit enter or type yes and hit enter.
This will create your ssh key inside C:\Users\yourusername\.ssh
Then you need to configure homestead by editing for Nginx
C:\Users\digitlimit\Homestead\Homestead.yaml
You can right-click Homestead.yaml file then click open then choose to open with wordpad.
My Homestead.yaml looks this after editing:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /wamp/www
to: /home/vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
NB: To understand the mapping which is a process of sharing a folder between the host and the VM:
My laravel project is located at C:\wamp\www\laravel
This directory /home/vagrant/Code will be inside the VM after installation.
So what am telling VM is, whenever you see /home/vagrant/Code reference this folder C:\wamp\www\laravel
Also in this:
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
What we are saying here is when i go to my browser and type http://laravel.dev display the content of /home/vagrant/Code/laravel/public which is actually pointing to C:\www\wamp\laravel\public
After editing Homestead.yaml file save your chnages
NB: Before we can use http://laravel.dev in the host web browser to view our laravel project, we need to add this the following to the hosts file located in
C:\Windows\System32\drivers\etc\hosts
Add this ip address under the list of other ip address listed if any:
192.168.10.10 laravel.dev
Finally, go back to your Git bash, ensure you are in
/c/Users/yourusername/homestead and type:
vagrant up
Wait for vagrant to complete its processes. Click yes when you see any dialog box asking for permission to create network adapter on your system
Any VM running on your development machine will be accessible when you're offline. Just make sure you setup your development machine's host file to have the VM's location set.
If you're following the Laravel Homestead Setup:
In scripts/homestead.rb, you'll have a line that has the IP Address of the VM.
# in scripts/homestead.rb
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
Add this IP address into to your hosts file. This is located usually in C:\Windows\System32\drivers\etc\hosts
#in hosts file
192.168.10.10 yourwebsite.dev

Resources