I can run my application in my local machine with docker compose. However, when I deploy my Streamlit app to the cloud, I can see that there is only one entry point.
So I have several questions.
Can I deploy the frontend and backend in the same app in Streamlit cloud?
Can I deploy the FastAPI app in another cloud app in order to connect both apps then?
In that case, I also tried to deploy my backend in another Streamlit Cloud app, but I see the error [Errno 98] error while attempting to bind on address ('127.0.0.1', 8000): address already in use
It’s great to see that you’re learning and experimenting with tools like Streamlit, FastAPI, and Docker for MLOps applications!
Let me try to answer your questions below:
Can I deploy the frontend and backend in the same app in Streamlit Cloud?
Streamlit is a great tool for building interactive, data-driven web apps, but it’s mainly designed for frontend purposes. You typically use it to present your machine learning models and not for running a backend like FastAPI.
Streamlit Cloud currently doesn’t provide support to run backend services, like FastAPI, concurrently with your Streamlit app. You will need to host your FastAPI backend somewhere else.
Can I deploy the FastAPI app in another cloud app in order to connect both apps then?
Yes, you can! You can deploy your FastAPI backend to a different cloud provider that supports running such applications. Services like AWS Elastic Beanstalk, Google Cloud Run, Heroku, Azure App Service can be used. Once your backend is deployed, you can connect to it from your Streamlit app by making HTTP requests to the URL where your FastAPI app is hosted.
Error: [Errno 98] error while attempting to bind on address (‘127.0.0.1’, 8000): address already in use
This error should mean that the port you’re trying to use (8000 in this case) is already being used by another process. I haven’t tried myself, but I believe you can usually resolve it by either stopping the process that’s currently using the port or by changing your application to use a different port.
I hope this answers your questions. Please try changing that port and see if it resolves your issues.
If not, there may be some other security considerations to review.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.