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” (126.96.36.199), port 5432 failed: FATAL: no pg_hba.conf entry for host “188.8.131.52”, user “db-user”, database “database-name”, SSL off
(Background on this error at: Error Messages — SQLAlchemy 2.0 Documentation)
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.
Thank you for your reply, @Caroline!
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 (184.108.40.206) 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 220.127.116.11 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
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.