Navdeesh Khurana
Navdeesh Khurana

Reputation: 13

when i vagrant up, port 80 is not forwarded

i get this output when i vagrant up, port 80 is not forwarding so how i will be able to access the site via web browser

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Setting the name of the VM: Homestead_default_1472822347316_22641
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!

help me ,thanks

Upvotes: 1

Views: 1437

Answers (2)

Eric Ihli
Eric Ihli

Reputation: 1907

Vagrant can't forward host ports < 1024.

So if you do config.vm.network "forwarded_port", guest: 80, host: 80 it won't work.

You can use a local SSH tunnel to listen on port 80 on your host and forward the traffic to port 80 on your guest.

sudo ssh -p 2222 -gNfL 80:localhost:80 vagrant@localhost -i ~/.vagrant.d/insecure_private_key

Upvotes: 0

mwp
mwp

Reputation: 8467

The default Vagrantfile, generated by vagrant init, includes an example of how to forward port 80:

# config.vm.network "forwarded_port", guest: 80, host: 8080

Simply uncomment this line and adjust the ports as necessary.

Upvotes: 1

Related Questions