DEV Community

Lightning Developer
Lightning Developer

Posted on

Skip the Cloud Setup: Expose Your Express.js App Securely from Localhost

When you’re developing with Express.js, building and testing web applications locally feels effortless. Everything runs smoothly on localhost:3000, responses are instant, and debugging is straightforward. But the moment you want to share your work-say, for a client demo, a team review, or webhook testing-things get complicated. Suddenly, you’re thinking about cloud deployments, port forwarding, or network configurations, just to let someone else access your app.

Fortunately, there’s a much simpler approach. In this guide, we’ll walk through how to make your local Express.js application publicly accessible in just a few steps using Pinggy, a lightweight tunneling tool. The best part? You don’t need to deploy to a server or modify your network settings.

What Makes Express.js So Popular?

Express.js is often called the backbone of the Node.js ecosystem—and for good reason. It’s a minimal yet powerful web framework that helps developers quickly build scalable web servers and APIs. Its flexibility lets you structure your application however you like, without unnecessary complexity.

Some of the reasons developers love Express.js include:

  • Freedom of design: It’s unopinionated, so you choose your architecture.
  • Intuitive routing: Makes managing HTTP methods and URLs simple.
  • Middleware system: Lets you add authentication, logging, or data parsing effortlessly.
  • Speed and scalability: Built on Node.js’s asynchronous architecture, it can handle thousands of requests efficiently.
  • Vibrant community: With countless extensions and tutorials available, support is never far away.

Whether you’re building a REST API, a backend for a mobile app, or a microservice, Express.js offers a clean foundation to move fast.

Why You Might Need to Share Your Local Express.js App

Running your app locally works perfectly for solo development, but it poses problems when you need others to interact with it. Consider these common scenarios:

  • Client Demos: Showing progress to clients often requires deployment or screen-sharing.
  • Team Collaboration: Remote teammates can’t test your app running on localhost.
  • Webhook Testing: Many APIs (like Stripe, Slack, or GitHub) require a public URL to send requests.
  • Mobile Testing: You can’t easily open localhost:3000 from your phone or tablet.

Usually, developers set up temporary servers or staging environments for these cases. But if you only need short-term or experimental access, that setup feels excessive. That’s where a tunneling tool like Pinggy saves the day; it securely exposes your local server to the internet within seconds.

Prerequisites

Before you start, make sure you have the following:

  • Node.js (v14 or higher): Downloadable from the official Node.js website.
  • npm or yarn: Installed automatically with Node.js.
  • SSH client: Preinstalled on macOS and Linux; for Windows, Git Bash or OpenSSH works fine.
  • Basic terminal knowledge: Enough to run simple commands.

A Pinggy account is optional unless you want advanced features like custom domains or persistent URLs.

Step 1: Setting Up a Simple Express.js Server

Let’s begin by creating a fresh Node.js project and adding a simple Express.js server.

1. Initialize a new project:

mkdir my-express-app
cd my-express-app
npm init -y
Enter fullscreen mode Exit fullscreen mode

This creates a package.json file with default settings.

2. Install Express.js:

npm install express
Enter fullscreen mode Exit fullscreen mode

3. Create a server file:
Create a new file called app.js and add the following code:

const express = require('express');
const app = express();
const PORT = 3000;

app.use(express.json());

app.get('/', (req, res) => {
  res.send('<h1>Welcome to Express.js!</h1><p>Your server is running successfully.</p>');
});

app.get('/api/hello', (req, res) => {
  res.json({ message: 'Hello from Express.js!', timestamp: new Date() });
});

app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});
Enter fullscreen mode Exit fullscreen mode

4. Start your server:

node app.js
Enter fullscreen mode Exit fullscreen mode

Visit http://localhost:3000 in your browser to see your app running.

Step 2: Expose Your Express.js Server Using Pinggy

Now that your server is live locally, let’s make it accessible to the world.

Open a new terminal window (keep the first one running your server) and run this command:

ssh -p 443 -R0:localhost:3000 -L4300:localhost:4300 -t free.pinggy.io
Enter fullscreen mode Exit fullscreen mode

Here’s what’s happening:

  • -p 443: Uses the HTTPS port, which works on most networks.
  • -R0:localhost:3000: Creates a reverse tunnel to your local Express.js port.
  • -L4300:localhost:4300: Enables a local web debugger for live request logs.
  • -t free.pinggy.io: Connects you to Pinggy’s public server.

After a few seconds, you’ll see a message like:

You can access the local server via the following URL(s):
https://rnssh-12-34-56-78.a.pinggy.link
Enter fullscreen mode Exit fullscreen mode

Open that URL in any browser, and your local Express.js app is now accessible online.

Step 3: Test and Debug Your Public App

Your app should load normally when accessed through the Pinggy URL. Try visiting:

https://your-generated-url.pinggy.link/api/hello
Enter fullscreen mode Exit fullscreen mode

You’ll get the same JSON response you saw locally.

You can also open the web debugger at:

http://localhost:4300
Enter fullscreen mode Exit fullscreen mode

It logs every incoming request—headers, payloads, and responses—which is incredibly helpful for testing webhooks or APIs.

Advanced Options with Pinggy

Pinggy provides a few extras that make sharing even more convenient:

1. Custom Domains
If you want a branded link (like demo.yourdomain.com), you can connect your own domain instead of using the default Pinggy subdomain.

2. Persistent URLs
Normally, the public URL changes every time you restart the tunnel. Upgrading to a plan with persistent URLs keeps your public link constant across sessions.

3. Password Protection
Add basic authentication for private access:

ssh -p 443 -R0:localhost:3000 -t free.pinggy.io b:username:password
Enter fullscreen mode Exit fullscreen mode

Only users with valid credentials will be able to reach your app.

When Sharing Your Localhost App Makes Sense

Sharing your local Express.js server through a tunnel is useful in many real-world cases:

  • Client Demos: Quickly show progress without a formal deployment.
  • Webhook Testing: Test Stripe or Twilio callbacks that need public endpoints.
  • Mobile and IoT Testing: Access your app from any device connected to the internet.
  • Collaboration: Let teammates test or debug remotely in real-time.
  • OAuth Flows: Easily test login callbacks for Google or GitHub sign-ins.

Conclusion

Setting up an Express.js app is easy—but sharing it shouldn’t require complex deployments. With tools like Pinggy, you can instantly turn your local development environment into a publicly reachable web app. It’s a small trick that saves a lot of time, especially for quick demos, client feedback, or API debugging.

Together, Express.js and Pinggy create a development workflow that feels effortless—build locally, test globally, and keep your focus on writing great code instead of configuring infrastructure.

Reference:

How to Share Your Express.js Application from Localhost

Top comments (0)