1

pyngrok multiple sessions setup

Hi, i'm trying to run 2 python files with pyngrok, but i receive next error:

The ngrok process errored on start: authentication failed: Your account is limited to 1 simultaneous ngrok agent session.
You can run multiple tunnels on a single agent session using a configuration file.
To learn more, see https://ngrok.com/docs/ngrok-agent/config/

i tried to change ngrok.yml file:

version: "2"
authtoken: *********
tunnels:
  first:
    addr: 8443
    proto: http    
  second:
    addr: 8444
    proto: http

And my .py files

1 file:

public_url = ngrok.connect(8443, "http").public_url

2 file

public_url = ngrok.connect(8444, "http").public_url

How to use multiple sessions with free acc and pyngrok?

tadman
  • 208,517
  • 23
  • 234
  • 262
Vadim M
  • 11
  • 2
  • "Your account is limited to 1 simultaneous ngrok agent session" should be a hint here. Maybe have more than one account? – tadman May 25 '23 at 22:21

2 Answers2

0

Make sure you are using the latest version of pyngrok that uses version 3.x of the ngrok Agent. The older version uses version 2.x of the ngrok Agent which starts both an http and https tunnels for the same endpoint by default. Defining two tunnels in the config file actually starts 4 tunnels. Version 3.x only starts the https tunnel by default.

0

To open multiply sessions with "PyNgrok" you need:

  1. Сhange the configuration file (which you already did)
  2. Write in the console ngrok ->ngrok start --all
  3. Run your web applications on these ports specified in the configuration without using PyNgrok. You just need to run localhost on the port and that's it. Next, ngrok will do everything himself.
BusinguZ
  • 1
  • 1