# How to run all servers from Python

**URL:** <https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086>\
**Category:** Rasa Open Source\
**Created:** [January 6, 2020, 6:05am UTC](https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086 "2020-01-06T06:05:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lloydkuijs](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lloydkuijs/32/6533_2.png) [@lloydkuijs](https://forum.rasa.com/u/lloydkuijs)\
**Post date:** [January 6, 2020, 6:05am UTC](https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086/1 "2020-01-06T06:05:39Z")

</div>

I want to run the NLU and action server from Python (rasa run && rasa run actions). I have thought of writing a BASH script that does it but I don’t like that idea since it limits my possibilities.

I wasn’t able to find any documentation on how to run the servers from Python and **not** through the terminal. I was looking through github and after a while I came up with this code.

```
from rasa.constants import DEFAULT_MODELS_PATH, DEFAULT_ENDPOINTS_PATH, DEFAULT_CREDENTIALS_PATH
from rasa.model import get_model, get_latest_model, get_model_subdirectories
from rasa.exceptions import ModelNotFound
import rasa

try:
    model_path = get_latest_model()
except ModelNotFound:
    print("No model found. Train a model before running the server using `rasa train nlu`.")

rasa.run(model=model_path, endpoints=DEFAULT_ENDPOINTS_PATH, 
        connector="rest", credentials=DEFAULT_CREDENTIALS_PATH)

```

This runs the NLU server but I couldn’t find how to make the action server run as well and this function doesn’t return until the application exits. Is there a function that exists when the server has started and keeps it running on a separate thread? I don’t want to keep sending messages to check if the server is online already.

Is it recommended to use the Agent defined here [Agent](https://rasa.com/docs/rasa/api/agent/) for this? If so, is there any sample code? Or, of course, any other sample code for what I am trying to do?

---

<div class="post-metadata">

**Author:** ![Ghostvv](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ghostvv/32/211_2.png) [@Ghostvv](https://forum.rasa.com/u/Ghostvv)\
**Post date:** [January 10, 2020, 3:24pm UTC](https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086/2 "2020-01-10T15:24:43Z")

</div>

we have docs that describe how to run rasa from Jupyter Notebook: [Jupyter Notebooks](https://rasa.com/docs/rasa/api/jupyter-notebooks/#id1)

---

<div class="post-metadata">

**Author:** ![deha](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@deha](https://forum.rasa.com/u/deha)\
**Post date:** [October 20, 2021, 8:19am UTC](https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086/3 "2021-10-20T08:19:59Z")

</div>

from rasa.exceptions import ModelNotFound

from rasa.model import get\_latest\_model

import rasa\_sdk. **main** as sdk

import argparse

import rasa.shared.utils.cli

try:

```
model_path = get_latest_model()

```

except ModelNotFound:

```
print("No model found. Train a model before running the server using `rasa train nlu`.")

```

args = argparse.Namespace(actions=‘actions’,port=5055,cors=None,ssl\_certificate=None,ssl\_keyfile=None,ssl\_password=None,auto\_reload=False,loglevel=None,log\_file=None)

sdk.main\_from\_args(args)

---

<div class="post-metadata">

**Author:** ![deha](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@deha](https://forum.rasa.com/u/deha)\
**Post date:** [October 20, 2021, 8:22am UTC](https://forum.rasa.com/t/how-to-run-all-servers-from-python/23086/4 "2021-10-20T08:22:57Z")

</div>

rasa run actions can be run with this code
