I am building an app to visualize elections data. I have a database in postgres that works perfectly fine in local environment but when i deploy to streamlit community cloud it gives me this error: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at “localhost” (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
Could someone help me please? I already looked up in stackoverflow but nothing worked. Thank you!
From the error message, it appears you have your code pointing to some local on your computer (localhost). Once you deploy an app to Community Cloud, your app can’t see anything on your computer. You’ll need to have your database hosted somewhere that is internet accessible so your app can speak to your database through a (nonlocal) IP or web address.
If you need further assistance, it would help to see your code. (Make sure you don’t have any database secrets or credentials visible.)
That’s definitely the problem then. Thank you so much for your quick answer, I’m a newbie in terms of databases. In your experience, where would you recommend me to host the database if its not locally on PostgreSQL? It weights 8GB. Thank you in advance for your help, since more than 1 day I’ve been stuck, at least now I know why.
It depends on what your use case is. (Is this critical where you want a solid service level guarantee or are you looking for something as cheap as possible, ideally free, even if it might not be as reliable.)
I mostly work in Azure, so that would be my go-to. The big players as usual are AWS, Azure, and GCP, but I’d have to defer to others in the community where to go for the cheapest solutions…
great. Thank you a lot. I will deep dive into that options, the traffic of the site will only be high during election times here in Argentina, then it will be low so I want the cheapest solution. Thanks!!
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.