14
votes

I have just installed ngrok on my local machine, ran

ngrok http 80

as usual.

However when I try to access port 80

localhost:80 

I get this error message

The connection to http://*******.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:80.

I am really unsure why this is occurring, and browsed around stackoverflow, but did not quite understand the answers I read. Hoping to diagnose afresh and build understanding from here.

OS is Mac OS.

4
Which OS are you using? On Linux/Unix open socket with port lower than 1024 is only allowed for root.mnille
Likely means Mac , I have the same issue nowRoy
I have the same issue on Mac, anyone found a solution to this? Thanks.Gabi Radu

4 Answers

8
votes

ngrok enables us to connect with http://xxx.ngrok.io with local server. Yup, all you do is just running server such as Apache, nginx or something. It is allowed build-in local server in your language.

sudo apachectl start
ngrok http 80

If you love PHP, you can follow below.

php -S localhost:8080
ngrok http 8080

Good Luck :D

2
votes

Simply do this

  1. Start your server using rail server
  2. Open your terminal and enter ngrok http 3000

N/B: The default rails local host is localhost:3000

This will generate some links for accessing your local host Copy the links and paste in your browser.

This worked for me.

2
votes

Try this to connect your local server to Ngrok. Start your server on the local host and expose the server port to Ngrok.

Lets say I am a running a rails app. To start my local server, I will hit

rail server

The default rails local host is

localhost:3000

And not localhost:8080

Enter localhost:3000 into your browser and ensure that it calls up your application. Once that's done, open your terminal or command line interface and type

ngrok http 3000

And not ngrok http 8080 or ngrok http 80, since your default port is 3000 and not 8080 or 80, except if you eventually change it to another port.

This should open up a GUI on the terminal, that shows all the network statistics and publicly accessible urls for the local server instance.

Open your preferred web browser and load either urls that are displayed next to “Forwarding”. e.g: https://.ngrok.io/api/v1/login

That’s all. You now have a web sever which is accessible from anywhere in the world.

That's all

I hope this helps.

1
votes

I was working on a Rails app I wanted to run it on ngrok but I got error below:

The connection to http://xxxxxx.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:3000.

It seems like ngrok works fine but my local server is not. Which is true since I forgot to run my rails app first by run $ rails s. After run my local server 3000 I was able to get ngrok works fine.

Once your local server runs first, head to your ngrok url and it should run as expected.

Good luck.