# Error using custom actions

**URL:** <https://forum.rasa.com/t/error-using-custom-actions/25051>\
**Category:** Rasa Open Source\
**Created:** [February 20, 2020, 11:30am UTC](https://forum.rasa.com/t/error-using-custom-actions/25051 "2020-02-20T11:30:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvbhanuteja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pvbhanuteja/32/7189_2.png) [@pvbhanuteja](https://forum.rasa.com/u/pvbhanuteja)\
**Post date:** [February 20, 2020, 11:30am UTC](https://forum.rasa.com/t/error-using-custom-actions/25051/1 "2020-02-20T11:30:02Z")

</div>

Hello i made a small custom action

but when i try to get it and if my story has that custom action i am getting this error

```
rasa.core.actions.action - Failed to run custom action 'action_fetch_profile'. Couldn't connect to the server at 'http://localhost:5055/webhook'. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [No route to host]
2020-02-20 16:49:50 ERROR rasa.core.processor - Encountered an exception while running action 'action_fetch_profile'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

```

this is how my custom action looks

```
from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
import requests
from rasa_sdk.actions import Action
from rasa_sdk.events import SlotSet
import xml.etree.ElementTree

def esb_api_call(payload,api_context):
    url = f'''https://myapi/{api_context}'''
    print(url)
    result = requests.post(url=url,data=payload,headers={'Content-Type': 'application/json'})
    return result

def accnum_by_mobile(mobile_number, count, last4digits):
        #my logic here
        return (count)

class FetchProfileAction(Action):
    def name(self) -> Text:
        return "action_fetch_profile"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        sender = tracker.sender_id
        count = accnum_by_mobile(sender, True, "")
        if(count == 0):
            return [SlotSet("account_count", "no_acc")]
        if(count == 1):
            return [SlotSet("account_count", "sinlge_acc")]
        if(count > 1):
            return [SlotSet("account_count", "multi_acc")]

```

and this this my endpoints.yml file

```
action_endpoint:
  url: "http://localhost:5055/webhook"

```

Looking at old error i tried changing the endpoints.yml file

after chnaging i got this error:

```
rasa.core.actions.action - Failed to run custom action 'action_fetch_profile'. Couldn't connect to the server at 'http://localhost:5055/webhook'. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [No route to host]
2020-02-20 16:49:50 ERROR rasa.core.processor - Encountered an exception while running action 'action_fetch_profile'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

```

can someone tell why i am getting that error and to fix.

i see my custom action is independent of endpoints.yml file, because i am doing the post request with in actions.py file

---

<div class="post-metadata">

**Author:** ![rishabhbatra10](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rishabhbatra10](https://forum.rasa.com/u/rishabhbatra10)\
**Post date:** [February 20, 2020, 12:07pm UTC](https://forum.rasa.com/t/error-using-custom-actions/25051/2 "2020-02-20T12:07:25Z")

</div>

Looks like your action server is not running that’s why you are facing this error.

Try running the following before in a separate terminal window: `rasa run actions`

---

<div class="post-metadata">

**Author:** ![pvbhanuteja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pvbhanuteja/32/7189_2.png) [@pvbhanuteja](https://forum.rasa.com/u/pvbhanuteja)\
**Post date:** [February 21, 2020, 9:41am UTC](https://forum.rasa.com/t/error-using-custom-actions/25051/3 "2020-02-21T09:41:28Z")

</div>

Why to I need a action server ? I am already doing a requests call in action.py isn’t it enough? I don’t get reason behind running action server

---

<div class="post-metadata">

**Author:** ![rishabhbatra10](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rishabhbatra10](https://forum.rasa.com/u/rishabhbatra10)\
**Post date:** [February 25, 2020, 8:03pm UTC](https://forum.rasa.com/t/error-using-custom-actions/25051/4 "2020-02-25T20:03:26Z")

</div>

In rasa’s architecture the custom actions run on a separate server than rasa’s main engine.

So first you run the action server which will actually use actions.py you define and register all the actions in it. By default this server is hosted on [http://localhost:5055/](http://localhost:5055/)

For this you use `rasa run actions`

Then `rasa run` or `rasa shell` uses this server internally to give you outputs.

You can look at the documentation here:

> **[Actions](https://rasa.com/docs/rasa/actions/)**

> **[Chitchat and FAQs](https://rasa.com/docs/rasa/chitchat-faqs/)**
