12

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.

Promise Preston
  • 8,732
  • 5
  • 43
  • 70
RPV
  • 367
  • 1
  • 2
  • 13

4 Answers4

8

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

Lupin
  • 81
  • 1
  • 4
  • Using ruby on Mac, you can start a local server with: "ruby -run -e httpd . -p [port number]" from the project root directory, then: "ngrok http [port number]" (create symlink to run ngrok from any directory) – Ben Sep 09 '17 at 13:13
2

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.

Promise Preston
  • 8,732
  • 5
  • 43
  • 70
2

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.

1

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.

egyamado
  • 1,013
  • 4
  • 22
  • 42