Streamlit component - Your app is having trouble loading the <> component

Hi all,

This might not be related to streamlit but it would be great if anyone can help me fix this issue.

I am trying to connect to a local react component (served on 3001 port) from streamlit and I am getting following error:

image

I have created two docker services - 1 for streamlit and 1 for react component and am running them on ec2 instance. Exposed ports: 8501 and 3001

Everything works if I replace http://localhost:3001 with http://<public_ip>:3001. Why is it not working with localhost?

localhost is not recognized even during network_mode “host” in docker compose file. only public ip seems to be working for some reason.

TLDR:
TO connect with a dev streamlit component, http://<public_ip>:3001 is working while http://localhost:3001 isn’t.