Failed to run custom actions error

I’m facing this error while running a action in action.py

ERROR rasa.core.actions.action - Failed to run custom action ‘action_pincode’. Couldn’t connect to the server at ‘http://localhost:5055/webhook’. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [Connection refused] ERROR rasa.core.processor - Encountered an exception while running action ‘action_pincode’. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

actions.py

class Actionpincode(Action): def name(self) -> Text: return ACTION_PINCODE

async def run(self,
              dispatcher: 'Dispatcher',
              tracker: 'DialogueStateTracker',
              domain: 'Domain') -> List[Event]:
    
    path = '/pincode.txt'
    pincode_file = open(path,'r')
    pincodes = pincode_file.read()
    print(pincodes)
    pin = next(tracker.get_latest_entity_values("pincode"), None)
    flag=0

    for i in pincodes:
        if i==pin:
            flag=1
    if flag==1:
        await dispatcher.utter_message("yes", tracker, silent_fail=True)
    else :
        await dispatcher.utter_message("no", tracker, silent_fail=True)

    return [UserUtteranceReverted()]

Hello @Saurbh060,

Did you start the action server ?

If yes, how are you running the Rasa server and action server, by command line or by Docker ?

If possible, post your action_server config in your endpoints.yml.

I’m running the server by command line if i use "rasa shell " command it will direct me to localhost

endpoints.yml -> action_endpoint: url: “http://localhost:5055/webhook

@Saurbh060

Yes, but did you start the action server by running the command: rasa run actions

@fuith Yes, I have already run this command and got this result

@Saurbh060 All right, as you can see when you start the action server there is an error, therefore your Rasa server can not connect to the action server to execute your custom actions. I check the constants.py in Rasa github and don’t see any constant named DOCS_BASE_URL, are you sure this is the right constant that you want to import ? This is the link to the constants.py on github: rasa/constants.py at master · RasaHQ/rasa · GitHub

@fuith I also checked my constants.py file but didn’t see any any consatnt named DOCS_BASE_URL and I don’t know what is the use of this file.

@Saurbh060

It said in the log that in you are importing DOCS_BASE_URL in your actions.py at line 11, is this not your intention ? Can you post your actions.py here ?

@fuith Actually I copied this file from somewhere to implement " action_default_fallback " but I think there are some unwanted things that were used in this file. actions.py (19.1 KB)

@Saurbh060

This seems to me like an outdated source code actions.py of Rasa. You should only define your own custom actions in your actions.py. I suggest you remove all the copied code and keep only your custom actions. The “action_default_fallback” is already implemented, if you want to customize it, just override it with your own logic.

@fuith ok, thanks :+1: