How to create multiple tunnels for multiple ports
If I have two local servers running on two different ports, starting multiple tunnels using this library doesn't work:
const url1 = await connect(8080);
const url2 = await connect(8081);
I get the following error:
msg: 'failed to start tunnel',
details: {
err: 'Your account may not run more than 2 tunnels over a single ngrok agent session.\n' +
'The tunnels already running on this session are:\n' +
'tn_2C0uSGv43kTabZHdSN4sQ8vH70k, tn_2C0uSGePhqjk7KNaNVJ2Eby6ZoR\n' +
'\r\n' +
'\r\n' +
'ERR_NGROK_324\r\n'
}
As the error message says, your account can only run 2 tunnels in a single ngrok session. When you start an HTTP tunnel with ngrok, it actually starts two for you, one on HTTP and one on HTTPS. So when you run the command connect(8000) it is actually starting two tunnels for you, so when you then try to run connect(8001) it tries to start tunnel 3 and 4. You can start only an HTTPS tunnel by passing the option bind_tls: true like so: connect(8000, { bind_tls: true });. If you only want HTTP, pass false as the option.
If you believe you have an account that can run more than 2 tunnels at a time, then you may not have your auth token set up correctly for the ngrok installation. If you think that's the case, you can set the auth token in the application by following the documentation here.
Hey @TimChandra, did my last comment help with your issue or are you still having trouble?
Please let me know so I can either help or close this issue. Thanks!
I'm going to close this, but if you are still having trouble, please feel free to reopen.