Effortless Port Forwarding with VS Code: Accessing Local Services Online
Tags: vscode, portforwarding
Published: 2023-09-29 11:03:42

---
title: Effortless Port Forwarding with VS Code: Accessing Local Services Online
published: true
date: 2023-09-20 12:38:20 UTC
tags: VSCode,portforwarding,vscode
canonical_url: https://codelila.com/vs-code-port-forwarding-access-local-services-online/
---

Hello friends, suppose you are developing a Web Application or a API and you want to expose it to few peoples or may be your clients. You want them to try the application/API quickly, ( **which is not hosted yet** ) and give their valuable feedback, so that you can make the necessary changes and then finally deploy it.

It was tiresome task previously. Rather I would say, we hardly thought that this could also be a possible way to implement and test the APIs or Web Applications. As sharing the application from local development environment was not so easy.

Now it has become simple and smooth by the use of VS code editor for development.

Let us see how we can do it stepwise.

Let us setup a sample react app. Go to the desired folder in command prompt and run this command to create a sample React app.

```
npx create-react-app my-demo-app
```

![](https://codelila.com/wp-content/uploads/2023/09/image-22.png)

Wait for it to complete. You may get the similar window as below.

![](https://codelila.com/wp-content/uploads/2023/09/image-23-1024x606.png)

Open the app in VS code using the given command on same terminal.

![](https://codelila.com/wp-content/uploads/2023/09/image-24.png)

Now go to VS Code editor you just opened and then open its terminal.

**Note:** Be sure you are on VS Code version 1.82 or the latest one. You can check for it by going to the **about** section.

![](https://codelila.com/wp-content/uploads/2023/09/image-25-1024x686.png)

Run the application, then type the below command on the terminal and press **Enter**.

```
npm start
```

By now the demo app must be ready and running.

![](https://codelila.com/wp-content/uploads/2023/09/image-26-1024x734.png)

## **PORT FORWARDING:**  **HOW TO SET PORT VISIBLITY TO PRIVATE.**

Go to **PORTS** tab on same panel where you run the above command. You will encounter the below options.

![](https://codelila.com/wp-content/uploads/2023/09/image-27.png)

Here you have to configure the port that you want to forward.

Right now the demo app is running on port 3000, and you want that to be accessible to your clients over the internet. For that you need to specify port 3000 in port column.

![](https://codelila.com/wp-content/uploads/2023/09/image-28-1024x243.png)

It will ask you to signin to GitHub, as given below.

![](https://codelila.com/wp-content/uploads/2023/09/image-29.png)

Click on “ **Allow”** and sign in on GitHub. After successful sign in, it will ask for permission to open the URI.

![](https://codelila.com/wp-content/uploads/2023/09/image-30.png)

Allow by clicking “ **Open** “. You may get the notification as below while it is progressing.

![](https://codelila.com/wp-content/uploads/2023/09/image-31-1024x212.png)

On completion, the port tab will have the entry for your port.

![](https://codelila.com/wp-content/uploads/2023/09/image-32-1024x122.png)

By default the visibility will be private and it will allow to access the forwarded address only if you signin in GitHub. This is one way to use the forwarded address.

Let us copy the forwarded address and open it on broswer.

![](https://codelila.com/wp-content/uploads/2023/09/image-33.png)

It will ask you to verify your identity.

![](https://codelila.com/wp-content/uploads/2023/09/image-34-1024x608.png)

Click “ **Authorize Dev Tunnels”** , and it will redirect you to the application. You might encounter somewhat similar warning window as below.

![](https://codelila.com/wp-content/uploads/2023/09/image-35-1024x688.png)

Click “ **Continue”** as we trust the URI/Application we are trying to access. You will see the application running on forwarded addess.

![](https://codelila.com/wp-content/uploads/2023/09/image-36-1024x680.png)

You can change the forwaded address to public, so that you are not asked for any GitHub authorizations. Let us expore that too.

## **PORT FORWARDING: HOW TO SET PORT VISIBLITY TO PUBLIC.**

Right click on the forwarded port entry and go to “ **Port Visibility** “.

![](https://codelila.com/wp-content/uploads/2023/09/image-37-1024x397.png)

make it “ **Public** “

Now, access the same forwarded address on browser. Here also, you will get some similar warning window as below.

![](https://codelila.com/wp-content/uploads/2023/09/image-38-1024x648.png)

click “ **Continue** “

and you will see the app runnning on forwarded port without doing any GitHub authentication/authorization.

![](https://codelila.com/wp-content/uploads/2023/09/image-39-1024x586.png)

You can also edit the port protocal. For this Right click on the port entry and go to “ **Change Port Protocol** “, then select “ **HTTPS** ” over there.

![](https://codelila.com/wp-content/uploads/2023/09/image-40-1024x380.png)

You can read more about port fowarding feature [here.](https://code.visualstudio.com/docs/editor/port-forwarding)

## Summary

In this blog post, we explored how Visual Studio Code (VS Code) simplifies the process of sharing and testing web applications and APIs. We started by creating a sample React app, then used VS Code to manage and run it effortlessly. VS Code’s “PORTS” tab allowed us to expose our app over the internet, with the option for GitHub authentication or making it public. We also learned how to enhance security by switching to the “HTTPS” protocol. Ultimately, VS Code proves to be an invaluable tool for developers, streamlining collaboration and ensuring polished results in web development.

The post [Effortless Port Forwarding with VS Code: Accessing Local Services Online](https://codelila.com/vs-code-port-forwarding-access-local-services-online/) appeared first on [CodeLila](https://codelila.com).