# Automating running the rasa servers

**URL:** <https://forum.rasa.com/t/automating-running-the-rasa-servers/59654>\
**Category:** Rasa Open Source\
**Created:** [September 13, 2023, 6:30pm UTC](https://forum.rasa.com/t/automating-running-the-rasa-servers/59654 "2023-09-13T18:30:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dse](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@dse](https://forum.rasa.com/u/dse)\
**Post date:** [September 13, 2023, 6:30pm UTC](https://forum.rasa.com/t/automating-running-the-rasa-servers/59654/1 "2023-09-13T18:30:29Z")

</div>

**I am trying to run the Rasa core and actions server automatically after training the model from a python script.**

However I get this **error** :

`Access to XMLHttpRequest at 'http://127.0.0.1:5055/webhook/' from origin 'http://127.0.0.1:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`

Even after adding the following into my Rasa Flask app.py :

```auto
from flask_cors import CORS

app = Flask( __name__ )
cors = CORS(app)
cors = CORS(app, origins=['http://127.0.0.1:8000']) #Django where i have the Rasa UI

```

**So I don’t understand why I get this error only when running the commands automatically and not manually.**

What could the problem be and how to fix it please ?

Thank you.

> **This is part of my code**
>
> I first stop running the servers then execute the commands to start the severs and generate log files to view the output.
> 
> The output looks the same as when running the commands manually.
> 
> ```auto
> log_action_path = "logs/rasa_actions.log"  
> log_core_path = "logs/rasa_core.log"  
> 
> stop_command = 'taskkill /F /IM "rasa.exe"'
> start_core_command = "rasa run -m models --enable-api --cors '*' --debug"
> start_actions_command = 'rasa run actions --cors "*" --debug'
> 
> try:
> result = subprocess.run(stop_command, shell=True, check=True)
> print('result is =',result)
> if result.returncode == 0:
> print('Stop Command completed successfully.')
> else:
> print('Stop Command - An error occurred.')
> 
> except subprocess.CalledProcessError:
> print("Rasa server is not running.")
> 
> # Open a log file for appending the output
> with open(log_action_path, "a") as log_file:
> # Create a subprocess with a new process group
> process = subprocess.Popen(
> start_actions_command,
> shell=True,
> stdout=log_file,
> stderr=subprocess.STDOUT, # Redirect stderr to stdout
> creationflags=subprocess.CREATE_NEW_CONSOLE,
> )
> 
> if process.poll() is None:
> print('The actions process has started and is still running.')
> else:
> print('The actions process has completed.')
>             
> ###### same for start_core_command ######
> 
> ```

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [September 20, 2023, 8:08pm UTC](https://forum.rasa.com/t/automating-running-the-rasa-servers/59654/2 "2023-09-20T20:08:18Z")

</div>

You may want to set the --cors option to `*` on the [rasa run](https://rasa.com/docs/rasa/command-line-interface/#rasa-run).

---

<div class="post-metadata">

**Author:** ![dse](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@dse](https://forum.rasa.com/u/dse)\
**Post date:** [September 20, 2023, 8:36pm UTC](https://forum.rasa.com/t/automating-running-the-rasa-servers/59654/3 "2023-09-20T20:36:24Z")

</div>

Yes i did already , the code is in the dropdown at the end of the post

`start_core_command = "rasa run -m models --enable-api --cors '*' --debug"`

It’s the same command i run manually in the terminal and get no problem, except when it is run as a subprocess.
