pipenet
pipenet is a Node.js library and CLI tool designed to instantly expose local development servers to the public internet, facilitating testing and collaboration without complex network configurations. Currently at version 1.4.0, the project demonstrates an active release cadence with several updates in early 2026, including features like adding hooks and shared tunnel server capabilities for cloud deployments. It offers both a command-line interface for quick usage and a programmatic API for deeper integration into automated workflows or testing environments. Key differentiators include the ability to request specific subdomains, support for custom upstream tunnel servers, and the option to run a self-hosted pipenet server with custom domains and multiple domain support, providing flexibility for various deployment scenarios. It ships with TypeScript types, promoting better developer experience in typed environments.
Common errors
-
Error: connect ECONNREFUSED ::1:3000
cause The local server pipenet is trying to expose is not running or not listening on the specified port.fixEnsure your local application is actively listening on the specified port (e.g., 3000) before starting the pipenet tunnel client. -
Failed to create pipenet tunnel: Subdomain 'myapp' already taken.
cause The requested subdomain is already in use by another client on the pipenet server.fixOmit the `subdomain` option to receive a randomly generated public URL, or try a different, unique subdomain name. -
Error: Your Node.js version (vX.Y.Z) is not supported. pipenet requires Node.js >=22.0.0.
cause The installed Node.js version on your system does not meet the minimum requirement specified by pipenet.fixUpgrade your Node.js environment to version 22.0.0 or higher. Tools like nvm (Node Version Manager) can help manage multiple Node.js versions.
Warnings
- gotcha Subdomain requests are not guaranteed. While you can request a specific subdomain, its availability is not guaranteed, and you might receive a different public URL.
- breaking Requires Node.js version 22.0.0 or higher. Running pipenet on older Node.js versions will result in an error or unexpected behavior due to engine requirements.
- gotcha CLI option name changed for bug fix in v1.2.1. Users upgrading from versions prior to 1.2.1 might encounter issues if they were using the previously incorrect CLI option name.
- gotcha The package is primarily designed for ES Modules (ESM) usage in modern Node.js environments (>=22.0.0).
Install
-
npm install pipenet -
yarn add pipenet -
pnpm add pipenet
Imports
- pipenet
const pipenet = require('pipenet');import { pipenet } from 'pipenet'; - createServer
import { createServer } from 'pipenet';import { createServer } from 'pipenet/server'; - Tunnel
import { Tunnel } from 'pipenet';import type { Tunnel } from 'pipenet';
Quickstart
import { pipenet } from 'pipenet';
import http from 'http';
import { AddressInfo } from 'net'; // For checking server address
async function startPipenetTunnel() {
// Create a simple local HTTP server to expose
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(`Hello from pipenet! Requested path: ${req.url}\n`);
});
const localPort = 3000;
server.listen(localPort, () => {
const address = server.address() as AddressInfo;
console.log(`Local HTTP server listening on ${address.address}:${address.port}`);
});
try {
// Create a pipenet tunnel to expose the local server
const tunnel = await pipenet({
port: localPort,
// host: 'https://pipenet.dev', // Defaults to pipenet.dev if not specified
subdomain: `my-test-app-${Math.random().toString(36).substring(2, 7)}` // Request a dynamic subdomain
});
console.log(`PTP Tunnel established! Public URL: ${tunnel.url}`);
tunnel.on('request', (info) => {
console.log(`[Tunnel Event] Request processed: ${info.method} ${info.path}`);
});
tunnel.on('error', (err) => {
console.error('[Tunnel Event] An error occurred:', err.message);
});
tunnel.on('close', () => {
console.log('[Tunnel Event] Tunnel has closed. Shutting down local server...');
server.close(() => console.log('Local server closed.'));
});
// Automatically close the tunnel after a period (e.g., 60 seconds) for demonstration
setTimeout(() => {
console.log('Automatically closing tunnel after 60 seconds...');
tunnel.close();
}, 60000);
} catch (error: any) {
console.error('Failed to create pipenet tunnel:', error.message);
server.close();
}
}
startPipenetTunnel();