0

How can I expose my localhost server for webhooks during development without third part services like ngrok?

I was watching this video on how to create a simple telegram bot and they have used ngrok to expose their localhost server to the internet for webhooks. I am trying to understand what problem ngrok and other services like this do.

How hard is it to expose your localhost server to the internet without third party services like ngrok and what are the disadvantages of doing that yourself?

YulePale
  • 6,688
  • 16
  • 46
  • 95

1 Answers1

1

Use NAT to expose a local server to the public internet. Your router should have a UI where you can map an external WAN port to a port on an internal machine.

It's straight forward to configure. The main disadvantage is that (unless you have purchased a static IP from your ISP) your WAN IP address will change occassionally. Meaning, you can't simply share/publish the public IP for your local dev server as it will change.

Lloyd
  • 8,204
  • 2
  • 38
  • 53
  • I understand. I think I have done something like this before. Correct me if I am wrong, but is this the same as [this](https://stackoverflow.com/q/56204838/9953550)? Where you basically expose your localhost server to other computers in your network? – YulePale Oct 09 '21 at 15:58
  • 1
    not quite - you can already access your local server from any other server on your local network, you don't need to configure anything in your router to do this.. find out your server's LAN IP address (e.g. mine is `192.168.0.200`) then, from a different machine, you can hit your server with something like `curl http://192.168.0.200:8000` (or whatever port you use) – Lloyd Oct 09 '21 at 16:37