The Current

Thought Leadership

ngrok: Public domains for local dev environments, even Laravel Homestead

Give your local Laravel Homestead VM a temporary public domain in seconds.

Developers: Have you ever worked on a codebase that required Oauth 2.0? Or maybe your code used a third-party service that would only work on a verified public domain. “That won’t work on my local environment,” you say. “I guess we’ll test it in production.” Wouldn’t it be nice if you could magically have a public domain for your local machine?

Enter ngrok. With a single command line instruction, you can connect your local code to a secure public domain for free. Now you can test Oauth, run your integrations and even send a link to your project (running on your local machine) to your client. Pretty neat! I’ll show you how to do it.

1. Setup

Start by downloading the zipped executable here. Unzip. Add the executable to your system PATH if you’d like. You can now run the command ngrok (or on Windows, ./ngrok).

I placed my executable in my ~/code/ directory and got this output:

2. Prepare Codebase

For this example, I pulled a fresh installation of Laravel to my local machine, set up Apache and created a virtual host called When I navigate to, of course I see the Laravel splash page:

3. Run ngrok

Now it’s time for some magic. On the command line, run ngrok http 80 (./ngrok http 80 on Windows). ngrok will run and listen.

You can kill it with CTRL+C like any other listening process.

Now navigate to http://localhost:4040. You’ll get your ngrok dashboard where your public domain will be listed.

Notice that you only get the domain for eight hours using the free account. Click on the domain (I prefer to use the HTTPS version) and take a look:

There you have it! You can send this website to a client for review, share it with a coworker or check it out on your phone.

ngrok will monitor domain requests to your website on its dashboard and provide some useful information for you.

Bonus: Connecting to Virtual Machines

Let’s say you develop using a VM. (I tend to use Laravel Homestead.) No problem! Set up ngrok so your VM is accessible by your public domain.

If you’re not familiar with Homestead, you can learn how to set up vagrant, clone Homestead and set up your configuration from the Laravel docs. My Homestead.yaml file looks like this:

ip: ""
memory: 4096
cpus: 4
provider: virtualbox

authorize: ~/.ssh/

- ~/.ssh/id_rsa

- map: ~/code
to: /home/vagrant/code
type: "nfs"

- map:
to: /home/vagrant/code/test/public

- test

This sets up a virtual box at which maps my code in /home/vagrant/code/test/public to the domain It also creates a database called test. If I navigate to my Homestead folder and type vagrant up the box will start. I create a file at /home/vagrant/code/test/public/index.html with the contents My test website. Now if I navigate to on my machine I see:

Now time for ngrok. Type in ./ngrok http Run this outside of the vagrant box (don’t ssh in and try to run it from inside).

Navigate to localhost:4040 to get the ngrok dashboard. Click on the new public domain.

Amazing! A public website hosted from your Homestead VM on your local development machine.


Your chance to get ahead. Our weekly FUTURE COMMERCE email delivers cutting-edge digital retail trends to your inbox so you know what's next. VOLTAGE is a digital agency specializing in eComm and digital brand experiences.

Like What You Read?

Share it. Your followers will thank you.

About Steven Cook

Steven Cook

Steven joined the team in 2008 as employee #1. Since then, he has gone through the ranks of Sr. Developer, Technical Director and President. Steven has an Bachelor's degree in Computer Engineering and a Master's degree in Computer Science from Brigham Young University.

View More Articles by Steven

Read More The Current