How to Host Localhost Globally Using Microsoft Dev Tunnels (Complete Guide)

Share your local development server with anyone over the internet using Microsoft Dev Tunnels, without deploying your application to a public server.9 min


Have you ever built a web application on your computer and wanted to show it to a client, teammate, or friend without deploying it to a hosting server?

Maybe you are developing a React application, testing a Java Spring Boot API, debugging a webhook, or working on a website that is not ready for production. In these situations, sharing your local development environment can be surprisingly useful.

One solution is Microsoft Dev Tunnels, a developer tunneling service that allows you to expose a locally running application through a URL accessible over the internet.

In this guide, we will learn how to host localhost globally using Dev Tunnels, understand how devtunnels.ms URLs work, install the command-line tool, configure access, and troubleshoot common problems.

You do not need to purchase a domain name or deploy your application to a public hosting server just to test it remotely.

What Is Microsoft Dev Tunnels?

Microsoft Dev Tunnels is a service that securely connects your local development environment to remote clients through a tunnel relay. Instead of requiring incoming connections directly to your computer, the service establishes an outbound connection from your development machine and forwards supported traffic through the relay.

For example, imagine your React application is running at:

http://localhost:3000

Normally, this address works only on your computer. Other people cannot open it directly from their devices over the internet.

With Dev Tunnels, your application can be made available through a URL similar to:

https://your-tunnel-3000.devtunnels.ms/

The actual URL is generated by the service and may look different.

Microsoft provides access controls so you can decide who is allowed to connect to your tunnel. By default, tunnel access is restricted rather than automatically public.

Official documentation: https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/

How Does Dev Tunnels Work?

A tunnel acts as a bridge between your local application and an internet-accessible endpoint.

The process is straightforward:

  1. You start a web application on your computer.
  2. Dev Tunnels connects your machine to its relay service.
  3. The service provides a URL for the configured local port.
  4. A remote browser or API client requests that URL.
  5. Dev Tunnels forwards the request to your local application and returns the response.

For example:

Local application: localhost:3000

Tunnel URL: https://your-tunnel-3000.devtunnels.ms/

Remote visitor: A client, tester, or teammate opening the tunnel URL.

Your application still runs on your computer. Dev Tunnels does not automatically deploy your code or database to the cloud.

Why Should Developers Use Dev Tunnels?

Dev Tunnels is particularly helpful when you need to share a development environment temporarily.

Common use cases include:

  • Client demonstrations: Show a website before deploying it to production.
  • API testing: Let remote developers test a locally running API.
  • Webhook development: Receive callbacks from external services during development.
  • Mobile testing: Access a local application from another device.
  • Team collaboration: Share work in progress without setting up public hosting.
  • Debugging: Reproduce and investigate issues with remote requests.
  • Full-stack development: Expose a frontend or backend port when testing integrations.

For example, a Java developer can expose a Spring Boot API running on port 8080, while a frontend developer can share a React application running on port 3000.

Keep in mind that authentication, CORS, application configuration, and third-party callback restrictions may still need to be configured separately.

Step 1: Install Microsoft Dev Tunnels CLI

The Dev Tunnels command-line interface, commonly called the devtunnel CLI, lets you create, host, and manage tunnels from a terminal.

You can use it with Windows, macOS, and Linux.

# Windows installation

On Windows, open PowerShell or Windows Terminal and use the installation method documented by Microsoft.

Microsoft’s official setup guide:

https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started

You can also install the CLI using Microsoft’s documented Windows Package Manager (winget) instructions, where supported.

After installation, open a new terminal and verify that the command is available:

devtunnel --version

If you see a version number, the CLI is available.

If Windows reports that devtunnel is not recognized, check that the installation completed successfully and that the executable is available on your system's PATH.

macOS and Linux installation

Open a terminal and run Microsoft’s documented installation script:

curl -sL https://aka.ms/DevTunnelCliInstall | bash

Review the installation source before executing a downloaded script, particularly on a managed or production development machine.

After installation, verify it:

devtunnel --version

For operating-system-specific details, use the official Microsoft documentation rather than an unverified third-party download.

Step 2: Sign In to Dev Tunnels

Before hosting a tunnel, authenticate with a supported account.

Run:

devtunnel user login

You can sign in using a supported Microsoft account, Microsoft Entra ID account, or GitHub account.

For GitHub authentication, use:

devtunnel user login -g

Once authentication is complete, you can create and host a tunnel.

Important Note: Anonymous tunnel creation is not supported. This does not mean every visitor must sign in, because tunnel access can be configured separately.

Step 3: Start Your Local Application

Before exposing localhost, make sure your application is running correctly.

For example, if you have a React development server, start it using your project’s usual command:

npm run dev

Depending on your tooling and configuration, your application might run at:

http://localhost:5173

For a React application using a typical Vite configuration, port 5173 is common.

Other common local development ports include:

These are examples, not fixed requirements. Always check the actual URL printed by your development server.

For this tutorial, we will use port 3000.

Step 4: Host Localhost Globally

Open a second terminal while keeping your application running.

Execute:

devtunnel host -p 3000

This command asks Dev Tunnels to create a temporary tunnel for the local service listening on port 3000.

If everything works, the CLI prints a tunnel ID and one or more URLs.

An illustrative URL might look like this:

https://example-3000.devtunnels.ms/

Your actual tunnel ID and URL will be different.

Open the displayed URL in your browser to test the connection.

What if your application uses another port?

Replace 3000 with the port your application actually uses.

For a Vite application running on port 5173:

devtunnel host -p 5173

For a Java Spring Boot API running on port 8080:

devtunnel host -p 8080

For an application using ports 3000 and 8080 simultaneously:

devtunnel host -p 3000 8080

The corresponding local services must already be running, and each port should use the appropriate protocol.

Step 5: Understand the devtunnels.ms URL

One of the most useful parts of Dev Tunnels is the URL generated for your local application.

A URL may resemble:

https://<tunnel-id>-<port>.devtunnels.ms/

The exact hostname format can vary depending on the tunnel configuration and service region.

The URL provides a remote entry point for the configured local port. It does not mean your application has been permanently deployed.

If the tunnel requires authentication, a visitor may be redirected to sign in before reaching your application.

If the visitor is not authorized, they will not be able to access the protected tunnel.

Can anyone open a Dev Tunnels URL?

Not necessarily.

By default, tunnels are private and accessible to the tunnel owner. You can grant access through supported authentication and access-control options.

If you explicitly allow anonymous access, visitors will not need to authenticate with an account to reach the tunnel. However, anyone who obtains the URL may be able to access the exposed service.

For that reason, choose the access configuration based on the purpose of your project.

Step 6: Share Your Localhost With Anyone

Suppose you want a client to review your website without deploying it to a production server.

You can follow this process:

  1. Start your local application.
  2. Run devtunnel host -p 3000.
  3. Copy the URL printed by the CLI.
  4. Configure the tunnel’s access permissions for the intended audience.
  5. Share the URL with your client.
  6. Keep your application and tunnel-hosting process running while the client tests it.

If the client needs anonymous browser access, configure that permission deliberately.

For a temporary demonstration where the application contains no sensitive data, you can run:

devtunnel host -p 3000 --allow-anonymous

This example creates a temporary tunnel with anonymous access enabled. It should only be used when you understand the exposure and the application is safe to make accessible without authentication.

Security reminder: Do not expose an application containing customer information, private APIs, administrative functions, or development credentials through anonymous access.

Step 7: Create a Reusable Dev Tunnel

The previous examples use temporary tunnels. If you repeatedly need to share the same development environment, you can create a named tunnel and reuse it.

Create a tunnel:

devtunnel create my-local-app

Add the port:

devtunnel port create my-local-app -p 3000 --protocol http

Host the existing tunnel:

devtunnel host my-local-app

Use the commands supported by your installed CLI version, and check the output for the tunnel’s actual URL.

A reusable tunnel can be more convenient than creating a new tunnel for every session. However, you should not assume that the URL will remain available indefinitely. Tunnel expiration, inactivity, and access settings still apply.

For additional commands, consult the official CLI reference:

https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/cli-commands

Step 8: Test Your Tunnel From Another Device

Once the tunnel is running, test it from a separate device or network.

For example:

  • Open the generated URL on your mobile phone.
  • Ask a teammate to test the application.
  • Use an API client to send requests to an exposed development endpoint.
  • Test a webhook integration that needs to reach your local service.

If the tunnel requires authentication, make sure the person testing it has the necessary permissions.

If the URL does not load, verify that the application is running, the correct port is exposed, and the tunnel-hosting process has not stopped.

Step 9: Use Dev Tunnels for APIs and Webhooks

Dev Tunnels is useful for more than frontend applications.

Imagine you are building a Java Spring Boot API:

@RestController
@RequestMapping("/api")
public class HelloController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello from localhost!";
    }
}

If the application runs on port 8080, start the tunnel:

devtunnel host -p 8080

You can then use the generated HTTPS URL as the base address for remote testing.

For example, if the tunnel URL is https://example-8080.devtunnels.ms/, your endpoint would be:

https://example-8080.devtunnels.ms/api/hello

Replace the example hostname with the actual URL generated by your CLI.

This approach can also help test webhook callbacks from third-party services, provided their callback requirements are compatible with the tunnel and your application.

For API testing, remember that authentication, request validation, CORS, and webhook signature verification are still your application’s responsibility.

Step 10: Stop the Tunnel

When you finish testing, stop the hosting process using:

Ctrl + C

This terminates the current hosting session and its active tunnel connections.

For temporary tunnels, the tunnel created by the hosting command is deleted when the process exits. For a previously created tunnel, the tunnel resource may remain available for later use, subject to its configuration and expiration.

Stopping a tunnel is a simple way to prevent further access through that active hosting session.

Dev Tunnels Security Best Practices

Sharing localhost is convenient, but it also introduces security considerations.

Follow these precautions before sharing your URL:

  1. Keep anonymous access disabled by default. Enable it only when public access is necessary.
  2. Avoid exposing sensitive services. Do not publish development databases, admin dashboards, or internal management APIs.
  3. Use test data. Avoid real customer records, production secrets, and confidential files.
  4. Keep authentication enabled. Use the tunnel’s access controls and your application’s own authentication where appropriate.
  5. Review your configuration. Make sure only the required ports are exposed.
  6. Stop tunnels after testing. Do not leave unnecessary development services accessible.
  7. Protect environment variables. Never share .env files, credentials, API keys, or private tokens.
  8. Remember that HTTPS is not authorization. Encryption protects traffic in transit, but it does not make a publicly accessible application private.

Microsoft documents the service’s access-control and transport-security model here:

https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/security

# Common Dev Tunnels Problems and Solutions

1. The devtunnel command is not recognized

The CLI may not be installed correctly, or its executable directory may not be on your PATH.

Solution: Verify the installation, open a new terminal, and check devtunnel --version.

2. The tunnel URL does not open

Your local server may have stopped, or you may have exposed the wrong port.

Solution: Open the local application first, confirm the port, and restart the tunnel using that port.

3. The browser requests authentication

This is expected when the tunnel is private.

Solution: Sign in with an authorized account or configure access for the intended audience.

4. The application works locally but not through the tunnel

Your application may depend on a hostname, an allowed origin, cookies, or local network settings.

Solution: Review your development server’s host binding, CORS policy, authentication callbacks, and trusted-host configuration.

5. API requests fail through the tunnel

An API may reject requests because of authentication, incorrect paths, CORS, or application-specific restrictions.

Solution: Inspect the HTTP response and server logs, and verify the endpoint using the generated URL.

6. The URL stops working later

Temporary tunnels and reusable tunnels have different lifecycles. A stopped host process, expiration, or access-policy change can prevent access.

Solution: Restart the host process, check the tunnel’s configuration, and verify its current URL and expiration.

For detailed diagnostics, consult the official CLI documentation and use the supported verbose option where appropriate.

Dev Tunnels vs Traditional Hosting

Dev Tunnels and traditional hosting solve different problems.

If you need to demonstrate a project, test a webhook, or share work in progress, Dev Tunnels can be convenient.

If you need a reliable public website for customers, use an appropriate production hosting environment instead.

# Frequently Asked Questions

1. How can I host localhost globally for free?

You can use Microsoft Dev Tunnels to expose a locally running service through an internet-accessible URL. Check Microsoft’s current terms and service availability for any applicable usage limits.

2. What is devtunnels.ms?

devtunnels.ms is a domain used by Microsoft's Dev Tunnels service to provide web-forwarding URLs for tunneled development services.

3. Do I need a domain name?

No. Dev Tunnels generates a URL for the configured tunnel, so you do not need to buy a separate domain just to share a development application.

4. Does my computer need to stay on?

Yes. Your local application and tunnel-hosting process need to remain available for the tunnel to forward requests to your computer.

5. Can I expose a React application?

Yes. Start your React development server, identify its local port, and host a tunnel for that port.

6. Can I expose a Java Spring Boot API?

Yes. If your Spring Boot application is listening on port 8080, you can run devtunnel host -p 8080 and use the generated URL to test its endpoints remotely.

7. Is anonymous access safe?

Anonymous access can be appropriate for a temporary demonstration of a non-sensitive application. It is risky for private applications, internal services, or systems containing sensitive data.

8. Can I use Dev Tunnels instead of production hosting?

It is best suited to development, debugging, and testing. Microsoft’s CLI documentation identifies the CLI as a preview feature and does not recommend it for production workloads. Review the current official documentation before relying on it for any business-critical use.

9. How do I stop sharing localhost?

Press Ctrl + C in the terminal running the tunnel host. Also review any reusable tunnel resources and access permissions you no longer need.

Final Thoughts

Microsoft Dev Tunnels offers developers a practical way to expose localhost to the internet without deploying an application to a public server.

Whether you work with React, Angular, Java Spring Boot, .NET, Python, or REST APIs, the workflow is similar: start your application, install and authenticate the CLI, expose the correct port, and share the generated URL with the intended audience.

The most important thing to remember is that sharing a local application is not the same as deploying a production website. Keep access controls enabled, avoid exposing sensitive services, and use production hosting when you need long-term public availability.

If you regularly demonstrate projects or test integrations, Dev Tunnels is a useful tool to add to your development workflow.

References & Official resources:


Discover more from 9Mood

Subscribe to get the latest posts sent to your email.


Like it? Share with your friends!

What's Your Reaction?

Lol Lol
0
Lol
WTF WTF
0
WTF
Cute Cute
0
Cute
Love Love
0
Love
Vomit Vomit
0
Vomit
Cry Cry
0
Cry
Wow Wow
0
Wow
Fail Fail
0
Fail
Angry Angry
0
Angry
Rakshit Shah

Legend

Hey Moodies, Kem chho ? - Majama? (Yeah, You guessed Right! I am from Gujarat, India) 25, Computer Engineer, Foodie, Gamer, Coder and may be a Traveller . > If I can’t, who else will? < You can reach out me by “Rakshitshah94” on 9MOod, Quora, Medium, Github, Instagram, snapchat, twitter, Even you can also google it to see me. I am everywhere, But I am not God. Feel free to text me.

0 Comments

Leave a Reply

Choose A Format
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Meme
Upload your own images to make custom memes
Poll
Voting to make decisions or determine opinions
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Personality quiz
Series of questions that intends to reveal something about the personality
is avocado good for breakfast? Sustainability Tips for Living Green Daily Photos Taken At Right Moment