How to make a local server have public IP to access anywhere

3mp3r0r
2 min readJul 17, 2021

--

For the impatient ones, here are the two commands you need. For others, i recommend giving it a full read.

• python3 -m http.server 8080

• ngrok http 8080

Don’t know about you but i come across many such moments when i have to share a file present on my machine with someone outside my LAN (or home network) to someone who cannot access my machine. I can configure a simple ftp server on my cmd but it will work only within a local network, not anywhere in the world (as per my knowledge. Let me know if there is another way out).

Go to the directory you want to make available, open your cmd in that directory and run the first command.

• python3 -m http.server 8080

This will create a localhost server. Now we need to tunnel this IP to a public IP. This is where ngrok comes into play. Donot close the current terminal and open another terminal tab for following command:

• ngrok http 8080

It will give you a URL (here, https://7f917d89491b.ngrok.io) which you can give to anyone across world to access your file/directory.

It also captures all the traffic for inspection, though you can see that on both tabs. It can be very handy and useful. Following images show the traffic, how many times the URL was accessed and/or tempered.

--

--