Hi,
I am trying to access PostgreSQL DB on A2 hosting from a deployed streamlit app and receive an error below:
PostgreSQL error: (psycopg2.OperationalError) connection to server at “user-name.a2hosted.com” (106.0.62.88), port 5432 failed: FATAL: no pg_hba.conf entry for host “34.127.88.74”, user “db-user”, database “database-name”, SSL off
A2 Hosting tech support say that whitelisted the IP address of my Streamlit app, however in the logs they don’t even see a connection request. I can connect to the DB from my local Streamlit app by using PuTTY tunneling as the hosting company suggested and perform all DB operations. However, the deployed application throws an exception above.
Unfortunately, if you need to allow-list the hosted app’s IP address, Streamlit Community Cloud won’t be the best hosting option, since it doesn’t offer stable outbound IP addresses. I’d recommend hosting your app on another platform that does offer stable outbound IP addresses, or running the app locally – check out our community deployment wiki here.
This makes sense, but there is one point actually to mention for clarification.
Each time (it has been a few days) I run the page, I get same IP address (34.127.88.74) to be displayed in the error message. The same address is allow-listed by the DB hosting company. Does that mean that the IP displayed is different than the one from which request sent?
Also, they don’t get any connection request from the same IP: “The IP address 34.127.88.74 is already allowed on our PostgreSQL configuration file. Also, the errors are not logging on our end regarding this connection.”
I asked the hosting company to see if there are requests from other IP addresses to confirm if the problem is exactly how you described and not anything from my side.
Streamlit Community Cloud doesn’t necessarily use consistent outbound IP addresses – I would assume that’s the cause of the issue you’re seeing, but unfortunately I can’t say that with 100% certainty
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.