Rasa bot is not working in localhost url

Hii,

I created a rasa chatbot in latest version and it is working fine in commandline and chat.html but while opening localhost url like http://localhost:5006 in chat.html it is showing “this site can’t be reached” How can I make this localhost url work??

thanks in advance!

hi @Mounika1 the issue due too CORS request, you need to enable cors while you run your rasa server, you can use the below command:

rasa run -m models --enable-api --cors “*” --debug

:slight_smile:

while running above command it is showing “hello from rasa” in localhost url and chat.html is empty. where our bot is running??

hey @Mounika1 can you tell me which UI you are using to connect your Rasa, I mean that chat.html? Can you please tell what’s in that chat.html? If you want you can try out this too it may help you:

<html>
<body>
<div id="webchat"/>
<div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-0.5.8.js"></script>
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "/get_started",
interval: 1000, // 1000 ms between each message
customData: {"userId": "123"}, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: "http://localhost:5005",
socketPath: "/socket.io/",
title: "Robosensus",
subtitle: "Bot",
inputTextFieldHint: "Type a message...",
connectingText: "Waiting for server...",
hideWhenNotConnected: true,
fullScreenMode: false,
profileAvatar: "https://cdn.images.express.co.uk/img/dynamic/151/590x/Robot-uprising-wipe-out-humans-sir-martin-rees-787501.jpg",
openLauncherImage: 'myCustomOpenImage.png',
closeLauncherImage: 'myCustomCloseImage.png',
params: {
  images: {
    dims: {
      width: 300,
      height: 200,
    }
  },
  storage: "local"
}
})
</script>

</body>
</html>

the above content I am using in chat.html

hey @Mounika1 sorry but I haven’t used the rasa-webchat yet :sweat_smile:

it’s ok

Run rasa run -m models --enable-api --cors “*” --debug

Before opening the html file.

I’m running this command on my AWS EC2 instance:

docker run --user 1000 -v $(pwd)/models:/app/models rasa/rasa:latest-full run -m models --enable-api --cors “*” --debug

and still localhost:5005 is not displaying hello message from rasa.

I’ve followed this for initial setup: Deploying your Rasa Assistant

I’ve tried with docker-compose too but still nothing loads in my localhost:5005 (ERR_CONNECTION_REFUSED)

version: '3.0'
services:
  rasa:
    image: rasa/rasa:latest-full
    ports:
      - 5005:5005
    volumes:
      - ./:/app
    command:
      - run
      - -m
      - models
      - --enable-api
      - --cors
      - "*"
      - --endpoints
      - endpoints.yml

Also my container is allowing traffic on that port:

image

There are my aws ec2 inbound rules:

I’ve also checked VPC Network ACL which looks OK:

I’ve also tried disabling my firewall and it still doesn’t work, here is my console after docker-compose up:

Can you help @JiteshGaikwad?

EDIT: I’ve tried this from aws console and it works:

but this same command doesn’t work from my local console, why is that?

EDIT2: Solved by accesing through my instance public IP and port 5005

Replace the url http://localhost:5005 with <Ec2 -publicIP>:5005