# Getting Started with Cloudflare Tunnels: A Step-by-Step Guide 🌐🚀

Securing and improving the speed of your online apps is more important than ever in the current digital era. A particularly noteworthy solution is Cloudflare Tunnels. You may open ports on your firewall and expose your local web server to the internet with this handy tool. This tutorial will assist you in understanding and using Cloudflare Tunnels, regardless of whether you're a developer testing a new project or a company owner trying to increase security.

<div data-node-type="callout">
<div data-node-type="callout-emoji">😊</div>
<div data-node-type="callout-text">Host Your Application on Your Laptop! 😂</div>
</div>

Why wait for deployment? With Cloudflare Tunnels, you can host your app right from your laptop!

* **No More "Did you push it to Git?"** – Your app is live on your laptop! 🖥️✨
    
* **Impress Your Friends** – “Oh, just hosting my app on my laptop!” 😎
    

Go ahead, showcase your project while sipping your coffee! ☕🎉

<div data-node-type="callout">
<div data-node-type="callout-emoji">👎</div>
<div data-node-type="callout-text">Avoid Hosting on Your Laptop Directly without using cloudflare tunnel or ngrok🚫</div>
</div>

[Read it why ?](https://verpex.com/blog/hosting-service-explained/can-i-host-a-website-on-my-computer#:~:text=Make%20sure%20hosting%20is%20allowed,every%20day%20of%20the%20week.)

# What Are Cloudflare Tunnels? 🕳️

Cloudflare Tunnels (formerly known as Argo Tunnels) create a secure, outbound-only connection between your server and Cloudflare's global network. This means you can protect your applications without exposing your server's IP address, which significantly enhances your security posture.

### Key Benefits of Using Cloudflare Tunnels:

* **Enhanced Security**: Protects your server from direct exposure to the internet.
    
* **Easy Setup**: Set up with just a few commands—no complex configurations required.
    
* **Global Load Balancing**: Routes traffic efficiently across multiple servers.
    

**Automatic HTTPS**: Ensures secure connections without manual SSL certificate management.

![](https://global.discourse-cdn.com/cloudflare/original/3X/7/e/7e8f31b6ad03104b2a6bcc18cd3671833ff1884f.png align="center")

## Story Time: Meet Alex 👨‍💻

Let's illustrate the power of Cloudflare Tunnels with a story. Meet Alex, a web developer who recently launched a personal blog. One evening, while working on a new feature, he decided to test it locally. However, he faced a common dilemma: how to showcase his work without compromising security.

**Enter Cloudflare Tunnels.** With just a few commands, Alex was able to expose his local development server securely. His friends and colleagues could now access his blog at a unique URL without the risk of exposing his local environment to potential attacks.

# How it works ?

Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. With Tunnel, you do not send traffic to an external IP — instead, a lightweight daemon in your infrastructure (`cloudflared`) creates outbound-only connections to Cloudflare’s global network. Cloudflare Tunnel can connect HTTP web servers, [SSH servers](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/use-cases/ssh/), [remote desktops](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/use-cases/rdp/), and other protocols safely to Cloudflare. This way, your origins can serve traffic through Cloudflare without being vulnerable to attacks that bypass Cloudflare.

Cloudflared establishes outbound connections (tunnels) between your resources and Cloudflare’s global network. Tunnels are persistent objects that route traffic to DNS records. Within the same tunnel, you can run as many ‘cloudflared’ processes (connectors) as needed. These processes will establish connections to Cloudflare and send traffic to the nearest Cloudflare data center.

Refer to our [reference architecture](https://developers.cloudflare.com/reference-architecture/architectures/sase/) for details on how to implement Cloudflare Tunnel into your existing infrastructure

![](https://developers.cloudflare.com/_astro/handshake.eh3a-Ml1_ZvgY0m.webp align="center")

## **Installing Cloudflare Tunnel**

Cloudflare Tunnel requires the installation of a lightweight server-side daemon, `cloudflared`, to connect your infrastructure to Cloudflare. If you are [creating a tunnel through the dashboard](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/), you can simply copy-paste the installation command shown in the dashboard.

To download and install `cloudflared` manually, use one of the following links.

## **GitHub repository**

`cloudflared` is an [open source project ↗](https://github.com/cloudflare/cloudflared) maintained by Cloudflare.

* [All releases ↗](https://github.com/cloudflare/cloudflared/releases)
    
* [Release notes ↗](https://github.com/cloudflare/cloudflared/blob/master/RELEASE_NOTES)
    

## **Latest release**

### **Linux**

You can download and install `cloudflared` via the [Cloudflare Package Repository ↗](https://pkg.cloudflare.com/).

Alternatively, download the latest release directly:

| **Type** | **amd64 / x86-64** | **x86 (32-bit)** | **ARM** | **ARM64** |
| --- | --- | --- | --- | --- |
| Binary | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64) |
| .deb | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386.deb) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm.deb) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb) |
| .rpm | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-x86_64.rpm) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386.rpm) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm.rpm) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-aarch64.rpm) |

### **macOS**

Download and install `cloudflared` via Homebrew:

**Terminal window**

```bash
brew install cloudflared
```

Alternatively, download the [latest Darwin arm64 release ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-arm64.tgz) or [latest Darwin amd64 release ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-darwin-amd64.tgz) directly.

### **Windows**

Download and install `cloudflared` via [winget ↗](https://learn.microsoft.com/en-us/windows/package-manager/winget/):

**Terminal window**

```bash
winget install --id Cloudflare.cloudflared
```

Alternatively, download the latest release directly:

| **Type** | **32-bit** | **64-bit** |
| --- | --- | --- |
| Executable | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-386.exe) | [Download ↗](https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe) |

<aside><p>Note</p><section><p>Instances of<span> </span><code>cloudflared</code><span> </span>do not automatically update on Windows. You will need to perform manual updates.</p></section></aside>

### **Docker**

A Docker image of `cloudflared` is [available on DockerHub ↗](https://hub.docker.com/r/cloudflare/cloudflared).

## **Deprecated releases**

Cloudflare supports versions of `cloudflared` that are within one year of the most recent release. Breaking changes unrelated to feature availability may be introduced that will impact versions released more than one year ago. For example, as of January 2023 Cloudflare will support `cloudflared` version 2023.1.1 to cloudflared 2022.1.1.

To update `cloudflared`, refer to [these instructions](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/update-cloudflared/).

<div data-node-type="callout">
<div data-node-type="callout-emoji">ℹ</div>
<div data-node-type="callout-text">Depends upon your os install the above cloudflared daemon</div>
</div>

# Check it cloudflare is correctly installed or not ?

Cloudflare Tunnel can be installed on Windows, Linux, and macOS. as above we will discuss.

Confirm that `cloudflared` is installed correctly by running `cloudflared --version` in your command line:

**Terminal window**

```bash
cloudflared --version
```

### Result shoud be 👇

```bash
cloudflared version 2021.5.9 (built 2021-05-21-1541 UTC)
```

## **Run a local service**

The easiest way to get up and running with Cloudflare Tunnel is to have an application running locally, such as a [React or](https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/) [Svelte site](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/). Whe[n you](https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/) are [develo](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/)ping an application with these frameworks, they will often make use of a `npm run develop` script, or something similar, which mounts the application and runs it on a [`localhost`](http://localhost) port. For example, the popular `create-react-app` tool runs your in-development React application on port `3000`, making it accessible at the [`http://localhost:3000`](http://localhost:3000) address.

## **Start a Cloudflare Tunnel**

With a local development server running, a new Cloudflare Tunnel can be instantiated by running `cloudflared tunn`[`el` in](https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/) a ne[w comm](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/)and line wi[ndow,](https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/) pass[ing in](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/) the `--url` flag with your [`localhost`](http://localhost) URL and port. `cloudflared` will output logs to your command line, including a banner with a tunnel URL:

**Terminal window**

```bash
cloudflared tunnel --url http://localhost:3000
```

```bash
2021-07-15T20:11:29Z INF Cannot determine default configuration path. No file [config.yml config.yaml] in [~/.cloudflared ~/.cloudflare-warp ~/cloudflare-warp /etc/cloudflared /usr/local/etc/cloudflared]2021-07-15T20:11:29Z INF Version 2021.5.92021-07-15T20:11:29Z INF GOOS: linux, GOVersion: devel +11087322f8 Fri Nov 13 03:04:52 2020 +0100, GoArch: amd642021-07-15T20:11:29Z INF Settings: map[url:http://localhost:3000]2021-07-15T20:11:29Z INF cloudflared will not automatically update when run from the shell. To enable auto-updates, run cloudflared as a service: https://developers.cloudflare.com/argo-tunnel/reference/service/2021-07-15T20:11:29Z INF Initial protocol h2mux2021-07-15T20:11:29Z INF Starting metrics server on 127.0.0.1:42527/metrics2021-07-15T20:11:29Z WRN Your version 2021.5.9 is outdated. We recommend upgrading it to 2021.7.02021-07-15T20:11:29Z INF Connection established connIndex=0 location=ATL2021-07-15T20:11:32Z INF Each HA connection's tunnel IDs: map[0:cx0nsiqs81fhrfb82pcq075kgs6cybr86v9vdv8vbcgu91y2nthg]2021-07-15T20:11:32Z INF +-------------------------------------------------------------+2021-07-15T20:11:32Z INF |  Your free tunnel has started! Visit it:                    |2021-07-15T20:11:32Z INF |    https://seasonal-deck-organisms-sf.trycloudflare.com     |2021-07-15T20:11:32Z INF +-------------------------------------------------------------+
```

In this example, the randomly-generated URL [`https://seasonal-deck-organisms-sf.trycloudflare.com`](https://seasonal-deck-organisms-sf.trycloudflare.com) has been created and assigned to your tunn[el in](https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/)stanc[e. Vis](https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/)iting this URL in a browser will show the application running, with requests being securely forwarded through Cloudflare’s global network, through the tunnel running on your machine, to [`localhost:3000`](http://localhost:3000):

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728822738488/6b8df491-3a15-4b02-b133-dcef26d18a05.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728823262355/d20b5d5c-88c3-49e2-8f01-0ec623ac07ca.png align="center")

# **Create a remotely-managed tunnel (dashboard)**

Follow this step-by-step guide to get your first tunnel up and running using Zero Trust.

## **Prerequisites**

Before you start, make sure you:

* [Add a website to Cloudflare](https://developers.cloudflare.com/fundamentals/setup/manage-domains/add-site/).
    
* [Change your domain nameservers to Cloudflare](https://developers.cloudflare.com/dns/zone-setups/full-setup/setup/).
    

## **1\. Create a tunnel**

1. Log in to [Zero Trust ↗](https://one.dash.cloudflare.com/) and go to **Networks** &gt; **Tunnels**.
    
2. Select **Create a tunnel**.
    
3. Choose **Cloudflared** for the connector type and select **Next**.
    
4. Enter a name for your tunnel. We suggest choosing a name that reflects the type of resources you want to connect through this tunnel (for example, `enterprise-VPC-01`).
    
5. Select **Save tunnel**.
    
6. Next, you will need to install `cloudflared` and run it. To do so, check that the environment under **Choose an environment** reflects the operating system on your machine, then copy the command in the box below and paste it into a terminal window. Run the command.
    
7. Once the command has finished running, your connector will appear in Zero Trust.
    
    ![Connector appearing in the UI after cloudflared has run](https://developers.cloudflare.com/_astro/connector.DgDJjokf_IrBTB.webp align="left")
    
8. Select **Next**.
    

The next steps depend on whether you want to [connect an application](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#2-connect-an-application) or [connect a network](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#3-connect-a-network).

## **2\. Connect an application**

Follow these steps to connect an application through your tunnel. If you are looking to connect a network, skip to the [Connect a network section](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#3-connect-a-network).

1. In the **Public Hostnames** tab, choose a **Domain** and specify any subdomain or path information.
    
2. Specify a service, for example `https://localhost:8000`.
    
3. Under **Additional application settings**, specify any [parameters](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/configure-tunnels/origin-configuration/) you would like to add to your tunnel configuration.
    
4. Select **Save tunnel**.
    

## **3\. Connect a network**

Follow these steps to connect a private network through your tunnel.

1. In the **Private Networks** tab, add an IP or CIDR.
    
2. Select **Save tunnel**.
    

## **4\. View your tunnel**

After saving the tunnel, you will be redirected to the **Tunnels** page. Look for your new tunnel to be listed along with its active connector.

![Tunnel appearing in the Tunnels table](https://developers.cloudflare.com/_astro/tunnel-table.D9VVGgDD_qjaM8.webp align="left")
