> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/tools/workflow/create-a-public-url-for-a-local-server.md).

# Create A Public URL For A Local Server

At times while developing an app locally, you need to expose the local server to the public internet. This can be useful and necessary when working on a 3rd-party integration or when you want to show what you have running locally to someone else.

In addition to tools like [ngrok](https://ngrok.com/), I've found the [`localtunnel`](https://github.com/localtunnel/localtunnel) npm package to be an effective way to quickly expose a localhost port.

```
$ npx localtunnel --port 3000 --subdomain some-custom-subdomain
your url is: https://some-custom-subdomain.loca.lt
```

This will create a `loca.lt` URL with the given subdomain that tunnels requests to `localhost:3000`. If the `--subdomain` flag is not specified or what you've specified isn't available, `localtunnel` will generate a random subdomain.

For the subdomain, I recommend using something sufficiently unique like `josh-branchaud-04092021`. Using the date has the added benefit of contextualizing when I generated the URL.

In my experience, these are not long-lived domains. Sometimes the connection gets interrupted and you'll have to restart it. Often when restarting, the specified subdomain will then be flagged as unavailable, so you have to tweak it a little.

Because it is using `npx`, there is nothing to install as long as you already have `node` itself installed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/tools/workflow/create-a-public-url-for-a-local-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
