How to expose localhost:4000 to the internet
Port 4000 is where your dev server lives right now. Here is how to put a public HTTPS URL in front of it without deploying.
Not as common as 3000, but Jekyll and a handful of other tools default here. The tunnel does not care what framework you run. It forwards HTTPS to whatever is bound on 4000.
Quick start
curl -fsSL https://get.ngsrv.com | bash
ngsrv token <YOUR_TOKEN>
ngsrv http 4000
You get a public URL like https://furry-otter-1842.tnl.ngsrv.com that routes to http://localhost:4000.
What usually runs on 4000
- Jekyll
- some Elixir/Phoenix setups
- misc Node apps
Typical dev command: bundle exec jekyll serve --port 4000
Install the CLI
# macOS (Homebrew)
brew install ngsrv/tap/ngsrv
# macOS / Linux
curl -fsSL https://get.ngsrv.com | bash
# Windows (PowerShell)
irm https://get.ngsrv.com/windows | iex
Sign up at ngsrv.com/register if you need a token. Free tier, no card.
Run the tunnel
With your server already up on port 4000:
ngsrv http 4000
Sample output:
forwarding https://furry-otter-1842.tnl.ngsrv.com -> http://localhost:4000
status online
Stable subdomain (optional)
Random names change when you restart. For webhooks or client previews, reserve one:
ngsrv http 4000 --subdomain site-preview
# -> https://site-preview.tnl.ngsrv.com
When it breaks
connection refused — Nothing is listening on 4000. Confirm with lsof -i :4000 (macOS/Linux) or netstat -ano | findstr :4000 (Windows).
401 invalid token — Re-run ngsrv token <YOUR_TOKEN> from the dashboard.
Tunnel drops — ngsrv reconnects on its own. Persistent drops usually mean VPN or proxy interference.