<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Deven Sitapara</title>
    <description>The latest articles on DEV Community by Deven Sitapara (@devens).</description>
    <link>https://dev.to/devens</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F223875%2F5ccec9b6-2b0f-4ece-bbc4-74d1764244f1.png</url>
      <title>DEV Community: Deven Sitapara</title>
      <link>https://dev.to/devens</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devens"/>
    <language>en</language>
    <item>
      <title>Expose Your Localhost to a Public URL</title>
      <dc:creator>Deven Sitapara</dc:creator>
      <pubDate>Tue, 17 Dec 2024 05:44:41 +0000</pubDate>
      <link>https://dev.to/devens/expose-your-localhost-to-a-public-url-35mc</link>
      <guid>https://dev.to/devens/expose-your-localhost-to-a-public-url-35mc</guid>
      <description>&lt;p&gt;When developing a local application, you might want to share it with others remotely or test it on external devices. Here are three popular tools—&lt;strong&gt;ngrok&lt;/strong&gt;, &lt;strong&gt;Localtunnel&lt;/strong&gt;, and &lt;strong&gt;Cloudflare Tunnel&lt;/strong&gt;—for creating a public URL for your local server.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Using &lt;strong&gt;ngrok&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ngrok&lt;/strong&gt; is a popular tool that creates secure tunnels, supporting HTTP, HTTPS, and TCP protocols.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install ngrok
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://ngrok.com/" rel="noopener noreferrer"&gt;ngrok’s official website&lt;/a&gt; and download the latest version of ngrok for your OS.&lt;/li&gt;
&lt;li&gt;Unzip the downloaded file and move the ngrok executable to a directory included in your system's PATH.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Set Up ngrok Authentication
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Sign up on ngrok to get an authentication token (this is required for free users to use ngrok).&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ngrok authtoken &amp;lt;your_auth_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Start an ngrok Tunnel
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In your terminal, navigate to the directory where your local server is running.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the following command (replace &lt;code&gt;3000&lt;/code&gt; with your server’s port):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ngrok http 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’ll see a public URL like &lt;code&gt;https://&amp;lt;random_string&amp;gt;.ngrok.io&lt;/code&gt; in the terminal. Use this URL to access your localhost from anywhere.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Secure, widely used, supports multiple protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Free version has a limited session time and random URLs.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Using &lt;strong&gt;Localtunnel&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Localtunnel is a simple and free solution that requires minimal setup. It’s ideal for quickly sharing local apps temporarily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Localtunnel
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Make sure you have Node.js installed, as Localtunnel is an npm package.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install Localtunnel globally with this command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; localtunnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Start a Localtunnel Session
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your terminal and navigate to the directory where your local server is running.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the following command (replace &lt;code&gt;3000&lt;/code&gt; with your server’s port):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lt &lt;span class="nt"&gt;--port&lt;/span&gt; 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’ll get a URL like &lt;code&gt;https://&amp;lt;random_string&amp;gt;.loca.lt&lt;/code&gt; that you can share.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Easy setup, no registration required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: URLs are random; no advanced security features.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Using &lt;strong&gt;Cloudflare Tunnel (Argo Tunnel)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare Tunnel&lt;/strong&gt; (previously Argo Tunnel) is a secure way to expose your localhost, protected by Cloudflare’s security features. It’s great for long-term use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Cloudflare’s CLI Tool
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;If you’re on macOS, run the following command to install Cloudflare’s CLI (&lt;code&gt;cloudflared&lt;/code&gt;):For other operating systems, visit Cloudflare Tunnel’s documentation to find the appropriate installer.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;cloudflared
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Start a Cloudflare Tunnel
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the following command to start a tunnel (replace &lt;code&gt;3000&lt;/code&gt; with your server’s port):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cloudflared tunnel &lt;span class="nt"&gt;--url&lt;/span&gt; http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloudflare will provide you with a public URL associated with your Cloudflare account.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Secure, reliable, and good for long-term access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Initial setup can be slightly more involved.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Installation Difficulty&lt;/th&gt;
&lt;th&gt;Security&lt;/th&gt;
&lt;th&gt;URL Type&lt;/th&gt;
&lt;th&gt;Best Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ngrok&lt;/td&gt;
&lt;td&gt;Easy&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Random (free)&lt;/td&gt;
&lt;td&gt;General, short-term sharing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Localtunnel&lt;/td&gt;
&lt;td&gt;Very easy&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Random&lt;/td&gt;
&lt;td&gt;Quick, temporary use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare Tunnel&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Very High&lt;/td&gt;
&lt;td&gt;Permanent (with account)&lt;/td&gt;
&lt;td&gt;Long-term, secure projects&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each tool offers unique advantages for sharing your localhost. Choose the one that best fits your needs, whether it’s a quick test or a more permanent, secure solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways of Using Tunneling Tools like above
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Ease of Sharing Local Servers
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Instantly share your development environment with external collaborators or testers without deployment.&lt;/li&gt;
&lt;li&gt;Access your app using a secure, public URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Cross-Device Testing
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Test locally hosted applications on external devices like phones, tablets, or other machines in different networks.&lt;/li&gt;
&lt;li&gt;Ensure compatibility across multiple devices and environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Convenient Collaboration
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Demonstrate app functionality to clients or stakeholders without deploying to a staging or production server.&lt;/li&gt;
&lt;li&gt;Collaborators can interact with the live local app in real time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Free to Start
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;All tools provide free tiers suitable for most personal and small-team use cases.&lt;/li&gt;
&lt;li&gt;Cost-effective for occasional remote access needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Minimal Setup
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Simple to install and run with minimal configuration, typically requiring just a single command to start.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using tools like ngrok, Localtunnel, and Cloudflare Tunnel enables rapid prototyping, collaboration, secure testing, and integration debugging, all while saving time and effort during local app development. These tools eliminate deployment barriers, helping developers focus on building and testing features without worrying about infrastructure setup.&lt;/p&gt;




</description>
      <category>webtool</category>
      <category>localhost</category>
      <category>tunnel</category>
    </item>
  </channel>
</rss>
