Skip to content

Instantly share code, notes, and snippets.

@jekkilekki
Last active November 13, 2017 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jekkilekki/ecb6eeaefb72ed47a61838397ba770d3 to your computer and use it in GitHub Desktop.
Save jekkilekki/ecb6eeaefb72ed47a61838397ba770d3 to your computer and use it in GitHub Desktop.
Vagrant Nginx binding error fix

I was the following problems with my VVV installation earlier this year. The following are the steps I took to fix things:

Update to PHP7

Since November PHP7 is the default for VVV, but at that time (Sept/Oct), it was not. But it was included on the [develop] branch (not [master]) of VVV.

  1. Switch to [develop] : git checkout develop
  2. git pull

nginx not binding to port 80

Shortly after that though (there may have been something else I installed that I overlooked - not necessarily VVV), I started getting the nginx bind() errors that are shown here in the other file. I used that other method for months to "bypass" my problems, but eventually decided to give it another go at fixing things.

  1. I updated everything (Vagrant, Virtual Box, VVV, even tried to update the Ubuntu distro, though it failed for various reasons)
  2. Updated Apple macOS Sierra's XCode (one of the updates in the App Store at that time)
  3. Tried to vagrant up again, but got multiple different errors
  4. Tried to do a fresh install in a totally NEW vagrant-new directory (vagrant-local was the original)
  5. Tried updating all the vagrant plugin installs
  6. Discovered that recent additions to VVV were "breaking changes" and I should do a git pull on that branch then a vagrant provision

But nothing worked right - I kept getting multiple, various errors.

Solution!

Finally I found a fix on the VVV GitHub Issues #1043 Mysql unrecognized service. I followed the same steps:

  1. Manually removed the Vagrant virtual machine from the VirtualBox GUI
  2. Had to do a rm -R vagrant-local in /Users/<username>/VirtualBox VMs/ to recursively remove all the files that I hadn't originally allowed the GUI to delete
  3. Copied Vagrantfile in the root directory to Vagrantfile.bak as a backup
  4. Reinitialized Vagrant with vagrant init in the root directory
  5. Copied Vagrantfile.bak's contents to the newly created Vagrantfile
  6. Ran vagrant up again

This time, FINALLY, everything went totally smoothly! Not a single red error message! Finally! You know how long I've waited to not see red? Wow - big relief. Now, back to dev work~~

# Recently I've had trouble with nginx binding on port 80 when I do a `vagrant up`
# Here's the fix I've found that works for me
# Errors received
# ==> default: * Restarting nginx nginx
# ==> default: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
# ==> default: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
# ==> default: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
# ==> default: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
# ==> default: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
# ==> default: nginx: [emerg] still could not bind()
# ==> default: ...fail!
# The SSH command responded with a non-zero exit status. Vagrant
# assumes that this means the command failed. The output for this command
# should be in the log above. Please read the output to determine what
# went wrong.
# My fix
# First, do vagrant up in order to gain access to the SSH shell
vagrant up
# Next, login to vagrant ssh to kill the process binding to port 80 and restart nginx
vagrant ssh
# Inside the vagrant ssh, kill the process binding to port 80
sudo fuser -k 80/tcp
# Response: 80/tcp: 2559 2610 2614 2617 2622 2628
# Restart nginx
sudo service nginx restart
# Finally, Control D out of vagrant ssh and reload your page - everything should work properly now
@1naveengiri
Copy link

Superb man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment