109

I am working on Facebook messenger.

My Facebook app only accept one url for a webhook but ngrok is generating a new URL every time. Now I am unable to test my app because the webhook URL has changed.

Russ Savage
  • 548
  • 2
  • 14
Saxid
  • 1,199
  • 2
  • 8
  • 6
  • 3
    UPDATE NOV 2018: See answer below with 39+ upvotes suggesting other services! https://stackoverflow.com/a/47500376/565877 – Devin Rhode Nov 07 '18 at 22:26

9 Answers9

191

UPDATE May 2020

Serveo is up and running again! No installation, no signup!

All you need to do is to run this:

ssh -R <unique subdomain>:80:<your local host>:<your local port> serveo.net

like

ssh -R youruniquesubdomain:80:localhost:8000 serveo.net

UPDATE January 2020

Since there are some issues with Serveo and localtunnel, I want to share with you another free ssh-based self-hosting service: Localhost.run

Unfortunately, it does not provide unique subdomains but it is ssh-based so you do not have to install additional applications. Still waiting for Serveo coming back.


UPDATE April 2018

I've found Serveo just now! And it is totally incredible!


UPDATE November 2017

Probably, it is not the best option for you but I started using localtunnel instead of ngrok.

An installation and run flow is very simple:

npm install -g localtunnel
lt --port <your localhost port> --subdomain youruniquesubdomain

Then I can go to my http://youruniquesubdomain.localtunnel.me That's it!

Eugene Kovalev
  • 3,407
  • 1
  • 15
  • 17
  • 1
    As I develop within a docker container, my virtual network runs off a `subdomain.localhost` URL. This tool does exactly what I needed. Thanks for the suggestion. – DazBaldwin Apr 10 '18 at 10:17
  • 3
    @DazBaldwin I've updated my answer just now. Serveo looks extremely incredible! – Eugene Kovalev Apr 19 '18 at 15:36
  • Though it seems like a great service. Serveo doesn't actually work for my needs. I'm not sure if it's because my local env is being served from within a docker container or something but local tunnel seems to be able to handle it. – DazBaldwin May 01 '18 at 09:50
  • "Invalid host header" when serving my angular app. All well when serving a separate app... hmm – Augie Gardner Jun 01 '18 at 05:30
  • 1
    Serveo is great! If you are looking for alternatives, there is also [Burrow.io](https://burrow.io). You create and manage tunnels via web interface, so you don't even need to type ssh commands. Just paste a CURL command and BAM, tunnel opened. – Paulo Arruda Aug 03 '18 at 20:58
  • 1
    @PauloArruda unfortunately it is not free :( But thank you for the info. it looks interesting – Eugene Kovalev Aug 06 '18 at 15:04
  • localchannel raise an error when you you define a subdomain: tunnel server offline: Request failed with status code 403 – M.Hassan Aug 27 '18 at 14:26
  • 11
    Automatically restart serveo after disconnect with `until ssh -R aw2xcd:80:localhost:5000 serveo.net; do echo "Restarting..."; done` – Chris Gunawardena Dec 29 '18 at 15:53
  • 1
    Google Chrome detects serveo.net as dangerous. "Warning – visiting this website may harm your computer!". – Shailesh Pratapwar Dec 31 '18 at 04:14
  • 1
    Servo is the best. The same URL every time you need. Better than ngrok. I strongly suggest to use it. – Mohith7548 Jan 10 '19 at 16:55
  • 1
    Serveo ... wtf? Free? No install? No signup? Why do people make such amazingly amazing things and then give them to me for free? This just saved me $5/month from ngrok which I was happy to pay. THANK YOU STACK OVERFLOW. – curiouscode Feb 19 '19 at 06:44
  • wow !! just wow you can resuse your domain name again as well. ngrok sucks!! – Develop4Life Mar 12 '19 at 13:29
  • Hey, Serveo does sound awesome, but when I run the command just as indicated, I get this when going to the browser: Bad Request - Invalid Hostname, do you know what might be going on? – Maximiliano Ambrosini Jun 06 '19 at 14:25
  • 1
    @MaximilianoAmbrosini probably that subdomain is occupied by someone else. I've just tried ssh -R youruniquesubdomaasdin:80:localhost:8000 serveo.net and it worked just fine – Eugene Kovalev Jun 06 '19 at 14:46
  • hmm I definitely used a unique subdomain, I'm not sure if it's related to it using https or something like that. – Maximiliano Ambrosini Jun 07 '19 at 15:05
  • Looks promising. Can you set custom host-name header like with ngrok? – Jón Trausti Arason Jul 12 '19 at 10:39
  • localtunnel is throwing just 404 and serveo is down due issues with phishing by malicious users – Ivan Castellanos Jan 03 '20 at 01:48
  • 1
    @IvanCastellanos seems like ngrok hackers are trying to take their money back lol – Eugene Kovalev Jan 03 '20 at 11:52
  • @IvanCastellanos I have updated my answer. It is not good as Serveo but not bad as ngrok or localtunnel. – Eugene Kovalev Jan 17 '20 at 14:36
  • @Qumber This is why I use localhost.run. Serveo proved itself as convenient but highly unstable – Eugene Kovalev Oct 09 '20 at 14:10
  • 1
    @EugeneKovalev Well I've tried localhost.run but it does not give stable sub-domains for free. I found this another service called [PageKite](https://pagekite.net) that lets you setup a subdomain and has a Pay What You Want pricing. Also it felt a bit faster to me. – Qumber Oct 10 '20 at 05:29
  • 1
    The Answer to "How to ...l with ngrok" is not "Install Serveo" – David Jan 12 '21 at 14:36
  • @David you are always welcome to pay for ngrok billing plans. The link to the one is right below my answer, left by Arvind Pattar. – Eugene Kovalev Jan 14 '21 at 13:55
  • 1
    Localhost.run works really well 27.01.2022! – leosok Jan 27 '22 at 14:45
  • Launched https://srv.us, which might or might not fare better. No account, no spyware (you'll have to trust that I run the code published…), subdomains are unique and persistent. – Pierre Carrier Jul 08 '22 at 23:34
21

You need to set up auth token. You can find it here https://dashboard.ngrok.com/auth. (W̶o̶r̶k̶s̶ ̶w̶i̶t̶h̶ ̶f̶r̶e̶e̶ ̶v̶e̶r̶s̶i̶o̶n̶,̶ ̶n̶o̶ ̶n̶e̶e̶d̶ ̶t̶o̶ ̶p̶a̶y̶ it's now paid feature, see ngrok pricing).

Then you can use it like this:

ngrok http 80 --subdomain yoursubdomain
Idan Gozlan
  • 3,173
  • 3
  • 30
  • 47
pbogut
  • 857
  • 1
  • 9
  • 22
  • 7
    Doesn't works. Still the same error. Tunnel session failed: Only paid plans may bind custom subdomains. Failed to bind the custom subdomain 'mysubdomain' for the account 'Ck Maurya'. This account is on the 'Free' plan. – Ck Maurya Sep 27 '16 at 17:17
  • That's really strange, I'm not paying a penny and I can use subdomain option. Maybe it's only working for some time on new accounts? – pbogut Sep 28 '16 at 07:33
  • I'm having the same problem as @CkMaurya =( – Adriano Tadao May 12 '17 at 12:28
  • What version of ngrok you are using? I have `ngrok version 2.0.19` installed, and when I run `ngrok http 80 -subdomain yoursubdomain` It works just fine. But as I said, token has to be set up. When I remove my token I'm getting same error. Maybe my account is somehow special, but I'm not paying for it. – pbogut May 12 '17 at 15:45
  • @pbogut are you still able to access it freely? – Mohammad Sadiq Shaikh Nov 12 '17 at 05:25
  • 1
    Version 2.2.8 gives `ERR_NGROK_313` when running the above command with an authentication token in use. – Steve Chambers Feb 24 '18 at 16:23
  • Ngrok appears to have changed their pricing. Going to their pricing page shows that "custom subdomains" is a feature available starting on the "Basic" account level. https://ngrok.com/pricing – Peter W Sep 10 '19 at 23:46
18

No more free subdomain support from ngrok.....pls have a error as below

Tunnel session failed: Only paid plans may bind custom subdomains. Failed to bind the custom subdomain 'arvindpattartestfb.ngrok.io' for the account 'arvccccc'. This account is on the 'Free' plan.

Upgrade to a paid plan at: https://dashboard.ngrok.com/billing/plan

ERR_NGROK_313

Arvind Pattar
  • 189
  • 1
  • 3
  • Indeed. ngrok message: `Tunnel session failed: Only paid plans may bind custom subdomains... Sign up at: https://ngrok.com/signup. If you have already signed up, make sure your authtoken is installed. Your authtoken is available on your dashboard: https://dashboard.ngrok.com`. – barak manos Feb 15 '17 at 09:59
  • 3
    when did this change and where was the announcement? – JackKalish Feb 20 '17 at 22:57
9

Neither localtunnel.me or Serveo are working for me right now so I created a temporary solution that works for some use-cases including mine (react-native local development): using the ngrok npm package one can save the generated ngrok url into a json file, and that file can be read for any other app.

First make sure to install ngrok using npm install ngrok then use this node script:

const ngrok = require('ngrok');
const fs = require('fs').promises;

(async function() {
  const url = await ngrok.connect(3000);
  const api = ngrok.getApi();
  let data = await api.get('api/tunnels');
  data = JSON.parse(data);
  let dict = {'domain': data.tunnels[0].public_url}
  await fs.writeFile("config.json", JSON.stringify(dict));
  console.log("saved " + data.tunnels[0].public_url);
})();

Then from your app you may read it using code similar or equal to:

const backend = require('./config.json').domain;
Ivan Castellanos
  • 8,041
  • 1
  • 47
  • 42
4

For DHIS2 local installation, I did this on the terminal on ubuntu server.

Make sure your web is running on the specified port. Mine was on 8080.

ssh -R dani.serveo.net:80:localhost:8080 serveo.net

The beauty of this serveo.net is you can reuse the same hostname prefix url before serveo.net as many time as you want, even if power goes off or internet diconnection.

cidermole
  • 5,662
  • 1
  • 15
  • 21
Develop4Life
  • 7,581
  • 8
  • 58
  • 76
3

Staqlab tunnel is providing domain for free. Its works great but need a binary to be downloaded from there website. Using this service for month without any hassle

abhishek
  • 41
  • 1
3

In 2022 (almost 2023) pagekite.me works for me. It is very similar to ngrok, and requires the installation of pagekite.py (and, obviously Python).

After installation click on pagekite.py opens pagekite shell.

Run command: 8080 subdomain.pagekite.me

Yuriy N.
  • 4,936
  • 2
  • 38
  • 31
2

I noticed that no one mentioned how to have static ngrok urls, which was the main question about.

A way to do it is to edit the ngrok.yml file, which is located at

Linux: "~/.config/ngrok/ngrok.yml"
MacOS (Darwin): "~/Library/Application Support/ngrok/ngrok.yml"
Windows: "%HOMEPATH%\AppData\Local\ngrok\ngrok.yml"

You can have content such as:

version: "2"
authtoken: valid_auth_token
tunnels:
  first-app:
    addr: 3000
    proto: http
    hostname: yourfixedngrok_id1.ngrok.io
  second-app:
    addr: 8000
    proto: http
    hostname: yourfixedngrok_id2.ngrok.io

This will help you expose multiple ports, and have a persisted url for each of which based on the value you set for hostnames.

After that, you run your ngrok using this command:

ngrok start --all
orabis
  • 2,749
  • 2
  • 13
  • 29
0

Though its not a solution but take it as workaround, I had the same problem while testing. What i did is keep the ngrok running with my http port, so my ngrok url is not changing. but I frequently changing and restarting my server for testing and debugging.

explorer
  • 39
  • 1
  • 9