158

I need to forward my localhost for a short period of time for testing purposes. It has to be accessed from the public internet.

How can I achieve this?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
George Leow
  • 2,193
  • 6
  • 23
  • 27
  • Wouldn't that belong on ServerFault? – 0xC0000022L Feb 24 '11 at 17:54
  • You cannot forward your localhost any more than you as a person can "forward" your self identity to someone else. Please explain what actual functionality you are trying to accomplish. – Chris Stratton Feb 24 '11 at 18:13
  • 2
    @STATUS_ACCESS_DENIED If you think a question is off topic, flag it and a moderator can move it to the right site – Dan Grossman Feb 24 '11 at 21:39
  • if you don't want to use third-party software and have your own SSH server then you can use TCP tunneling with SSH for exposing the localhost. See here https://nspointers.com/programming/expose-localhost/ – Gopal Singh Sirvi May 14 '20 at 07:13

6 Answers6

288

There are a couple of good free services that let you do the same. Ideal for showing something quickly during development/testing:

double-beep
  • 5,031
  • 17
  • 33
  • 41
Saurabh Kumar
  • 5,576
  • 4
  • 21
  • 30
  • 4
    + https://serveo.net – Emre Jun 11 '19 at 20:45
  • 7
    Thanks! localhost.run worked for me, while localtunnel.me didn't but maybe there is an issue on my side or system. Saw the 'pricing' wording on the ngrok site so didn't try it. – Edwin Yip Jul 13 '19 at 08:31
  • 1
    Used localhost.run.. I'm able to expose port 3000 not just the specified 8080. Thanks – MadCoder May 12 '20 at 17:26
  • Recently learned about https://tunnelin.com which can be added to your list. Also, http://localtunnel.me/ not working anymore. – simon Jun 04 '20 at 22:05
  • I'm trying localhost.run but every time it generates a URL for me, I go to the URL, then in the CMD it shows closed by remote host. What am I doing wrong? – garek007 Apr 29 '21 at 16:10
  • don't use ngrok or similar tools https://blog.cyble.com/2021/02/15/ngrok-platform-abused-by-hackers-to-deliver-a-new-wave-of-phishing-attacks/ – sultanmyrza Apr 16 '22 at 05:57
  • 2
    Huge + for Cloudflare Tunnel option. – Amrut Prabhu May 15 '22 at 22:55
  • 1
    Hi, I wrote an article on setting a tunnel using Cloudflared. I hope it helps: https://blog.continium-labs.com/how-to-connect-to-local-development-server-from-internet/ – Brlja Jul 01 '22 at 09:23
35

You go into your router configuration and forward port 80 to the LAN IP of the computer running the web server.

Then anyone outside your network (but not you inside the network) can access your site using your WAN IP address (whatismyipcom).

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
5

Even though you didn't provide enough information to answer this question properly, your best shots are SSH tunnels (or reverse SSH tunnels).

You only need one SSH server on your internal or remote network to provide access to your local machine.

You can use PUTTY (it has a GUI) on Windows to create your tunnel.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
2

use your ip address or a service like noip.com if you need something more practical. Then eventually configure your router properly so incoming connection will be forwarded to the machine with the server running.

Rabib
  • 51
  • 1
  • 10
EnricoOrs.
  • 94
  • 2
-3

You are accesing localhost, meaning you have a web server running on your machine. To access it from Internet, you need to assign a public IP address to your machine. Then you can access http://<public_ip>:<port>/. Port number is normally 80.

Barun
  • 2,542
  • 33
  • 35
-13

Try with your IP Address , I think you can access it by internet.

XMen
  • 29,384
  • 41
  • 99
  • 151
  • 7
    Most likely, his IP address will be a local network one, so behind a router and/or firewall, and not directly accessible by internet. He needs to expose his local server to the public internet over a tunnel. – Jochem Schulenklopper Apr 26 '18 at 12:43