Backend and Infrastructure

Connecting to Your Web Server

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Alternate resources

Sprout Video

In order to "find" our virtual server in a Web browser, we need to make a map between the two host machine, and your guest server. To do this we will use a technique referred to as port forwarding. This allows any communication from the host machine (your Web browser) to be automatically redirected to the appropriate location on your guest machine (the Web server). Fortunately this is very simple to do. In this lesson we are going to map port 4567 traffic on the host machine, onto the standard Web port, 80, on the server. This means when you access Web traffic at http://localhost:4567, it will be automatically redirected to Apache on your server. It's almost like a sleight of hand magic trick where a rabbit appears in a hat, but way cooler.

Lesson Outcomes

By the end of this lesson you will be able to correctly configure your server's network settings so that Web pages can be viewed in a browser on your host machine.

Lesson Summary

  1. Edit your Vagrantfile (Vagrant configuration file to set the following properties:
  2. Configure port forwarding "forwarded_port", guest: 80, host: 4567
  3. Reload the vagrant instance.
    $ vagrant reload
  4. Log into the server, confirm Apache is running. (Hint: it's not running.)
    $ curl 'http://localhost:80'
  5. Start Apache.
    $ /etc/init.d/apache2 start
  6. In a Web browser, navigate to:
    (Hopefully) It works!


This can sometimes be the tricky bit, especially if you already have a lot of custom network configuration. If this lesson doesn't work for you, you will need to do an audit of your system to find any software which might be interfering with the connection. We're going to limit ourselves to one VM running at a time (all the same ports). This is mostly because of the hardware limitations I expect you'll have. If your machine is more powerful, great! But we're not covering it in this video series.