Laravel Homestead - How to edit homestead.rb when virtualbox not running? - laravel-4

I attempted the top answer on this thread:
Vagrant port forwarding 80 to 8000 with Laravel Homestead
which was to make this change in the homestead.rb file:
config.vm.network "forwarded_port", guest: 80, host: 8000 to
config.vm.network "forwarded_port", guest: 80, host: 80
I am running a newer version of homestead (not sure where to find the exact version), on a mac.
It did not work, when attempting to start up my homestead virtualbox it now says:
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening on
these ports. The forwarded port to 80 is already in use on the host
machine.
I had edited the homestead.rb file via ssh and vim while the homestead virtualbox was running, but now I can't get it to run and I can't figure out how to undo my changes.
Help with both of these would be greatly appreciated!
How to edit the homestead.rb file when the virtualbox is not running? I believe it is inside either VirtualBox VMs/homestead/homestead.vbox or box-disk1.vmdk, but I do not know how to access inside them.
Help with getting the port to forward correctly to 80 since the solution from the other question did not work.

Homestead 2.+ stores it's files inside your .composer directory inside your User directory. For example, for me it is in:
/Users/noel/.composer/vendor/laravel/homestead
You will find all the configuration and script files that used to reside in the older Homestead 1.0 directories.
Now, since something is holding on to your port 80, it probably means that your local apache installation is running. You can test to see what is holding on to the port by running:
sudo lsof -i :80
To list all processes listening on port 80 (incoming and outgoing).
To stop the local apache you can run:
sudo apachectl stop
That should release the port for you to use with your virtual machine.

Related

Drupal-vm port forward

I have drupalvm setup which has drupal installed. In my custom theme, I have styleguide running on port 6006 (can be configured to different as well as it's node app). I want to expose this to host system. when I do vagrant ssh -- -L 6006:localhost:6006 it's works fine and available on host. Now I have added below to Vagrantfile to make this permanent (as per document here - http://docs.drupalvm.com/en/latest/extending/vagrantfile/):
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 6006, host: 6006
end
Now I can see this port forwarded when I do vagrant port But I can't access localhost:6006 (or use already working drupal hostname - local.drupal.com:6006) on host machine. Do I have to add vhost for it in vagrant, if yes how? OR is there any other way to expose node app to host?

Vagrant - vagrant cannot forward the specified ports on this VM

When i run vagrant up i get the following error:
Vagrant cannot forward the specified ports on this VM, since they
would collide with another VirtualBox virtual machine's forwarded
ports! The forwarded port to 3306 is already in use on the host
machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.forward_port 80, 1234
I checked and i don't have any processes using port 3306 locally.
I also tried vagrant destroy and vagrant up, didn't help.
vagrant suspend followed by vagrant resume didn't help as well.
What else could be the issue?
What's your command to find the port?
Maybe you can see this. Vagrant Port Collision on Port 80, but Port 80 is not Forwarded in the VagrantFile
Turns out there was a process on my machine running on port 3306.
Running lsof -i :3306 didn't show it, only when i used sudo it did.

How to route and network Vagrant VM instances?

I have recently started using Vagrant instead of MAMP for some small projects (mainly WordPress) However, decided to try my hand at React and am wondering wether it is possible to use the two together?
At the moment I have a Vagrant setup created via PuPHPet which works fine and runs a local server on a VM which I can access via a URL - local.gethandle.com. I also downloaded a React starter kit as a starting point from a Facebook github page and it requires you to run a server e.g. node server.js which also works and I can access from a separate URL - http://localhost:3000/. But cant seem to access my React application via my Vagrant URL.
How do I combine the two? If at all possible.
Oki doki,
caveat: I've not looked at what kind of VM is provisioned via PuPHPet..
First you'll need to vagrant ssh into your vagrant vm and download the react tools into your vagrant vm
https://docs.vagrantup.com/v2/getting-started/up.html
Second you'll then want to edit your Vagrant file that should be in the directory on your machine where your vagrant settings are, then have a look and add some networking config
https://docs.vagrantup.com/v2/getting-started/networking.html
config.vm.network :forwarded_port, guest: 80, host: 4567
# guest is your machine, host is your vagrant vm
# e.g config.vm.network :forwarded_port, guest: 3000, host: 3000
You probably need to add the port to your firewall:

Vagrant port forwarding not working on Mavericks

I'm using a vagrant Geodjango box and port forwarding is not working for me.
On the box, I have run:
python manage.py runserver 0.0.0.0:8000
But http://localhost:8000 and http://localhost:4567 both find nothing on the host machine.
On the Vagrant box, curl -v 'http://localhost:8000/' gives the usual:
<h2>Congratulations on your first Django-powered page.</h2>
which suggests that Django is running okay. But on the host machine, trying curl -v 'http://localhost:8000/' gives the following output:
curl: (7) Failed connect to localhost:8000; Connection refused
My Vagrantfile has the following port forwarding set up:
config.vm.forward_port 8000, 4567
Disabling the Mac's firewall does not help and stopping Apache makes no difference. I have tried running lsof -i :8000 on the host machine and there is no output, so I figure nothing is using the port.
Can anyone suggest anything?
I had the same issue on Yosemite and none of the ports were forwarding. Disabling the Firewall filter on the guest machine helped:
sudo service iptables stop
Good to see you figured it out yourself.
Just want to add my 2 cents, in V2 Vagrantfile, the port forwarding code block is like below, try to use the new ones so as to avoid port conflicts (back in v1 I always got confused which is which).
config.vm.forward_port 8000, 4567 is forwarding guest port 8000 to host 4567, not the other way around.
In V2 format, it looks like below, which is clearer from my opinion
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end

Vagrant port forwarding not working. Cups not accesible from host

So I'm working with vagrant and I'm trying to use it as a printing server. I installed cups.
Internally everything works just fine. I can even make a quick curl to my localhost:631 (cups port inside my vagrant) and there's everything.
The thing is I cant access it in any way I try from the host machine.
Obviously I forwarded the port and I've tried with several ports. I've also tried with Debian squeeze and Ubuntu 12.04. Here is my current Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "guruDebian"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 631, host: 6363 ## HERE IS CUPS
end
Any ideas?
I think what you will find is that the default cups config file is locked down to only work from localhost for security reasons.
Inside your Vagrant VM open the /etc/cups/cupsd.conf file and change the following line:
Listen localhost:631
to
Listen 0.0.0.0:631
That should allow you to connect from any host.
Have you tried accessing port 8080 of guest to your host? if no, and the services inside guest are running. then its a firewall issue in guest.
Try to turn firewall temporarily
service iptables off
then try to access it again from host.

Resources