· App Development · 2 min read
Connecting To Localhost - The Easy Way
As a developer, there are instances when you need to make your localhost environment accessible from any device, anywhere, for testing or collaboration.

Overview:
When you need to expose your local development environment for testing or sharing, Localhost.run
offers a simple solution. This tool allows you to securely make your localhost accessible from anywhere without complex configurations.
What Is Localhost.run?
Localhost.run
is a service that uses SSH tunnels
to expose your local server to the internet
by creating a public URL
. It’s useful for testing, sharing, or allowing remote access to your development environment.
Prerequisites:
- A running local server (Node.js, Python, etc.)
- SSH client (pre-installed on most systems)
- A terminal to run commands
Steps to Connect
- Install SSH (If Needed):
macOS/Linux: Typically pre-installed; check with ssh -V. Windows: Install OpenSSH or use Git Bash. 2. Start Your Local Server: Ensure your server is running. For example, for Node.js:
node app.js
- Expose Your Localhost with Localhost.run: Run the following SSH command, replacing
PORT_NUMBER
with your server’s port:
ssh -R 80:localhost:PORT_NUMBER localhost.run
For example, if your server is on port 3000:
ssh -R 80:localhost:3000 localhost.run
You’ll receive a public URL like https://<random-id>.localhost.run.
and a QR code
to scan with your phone camera to access the public link
4. Test the Connection:
Open the URL in any browser to access your localhost from anywhere.
5. Secure Your Localhost (Optional):
For sensitive data, add authentication layers like Basic Authentication or ACLs. Example for Express:
const express = require('express');
const basicAuth = require('express-basic-auth');
const app = express();
app.use(basicAuth({ users: { 'admin': 'password' }, challenge: true }));
app.listen(3000);
6. Stop the Tunnel:
To disconnect, press Ctrl + C
in the terminal.