Using Google Cloud SQL Auth Proxy through Streamlit Cloud

Hello all, I am a bit of a newbie with all this so please bear with me :slight_smile:

I am trying to deploy an app on streamlit cloud so my fitness clients can access workouts, log and track progress etc. Everything works perfectly locally but when I try and deploy to streamlit cloud I get an error in the first few lines of my app() when it is supposed to connect to my database. The error is

OSError: [Errno 8] Exec format error: ‘./cloud-sql-proxy’

The code that produces the error is:

def app():
st.set_page_config(page_title=“Cabral Fitness Exercise Prescriptions”)
with st.spinner(‘Connecting to Cloud…Please Wait’):

    # Start the Cloud SQL proxy when the application starts
    proxy_process = subprocess.Popen(
    ['./cloud-sql-proxy', '--address', st.secrets.proxy_credentials.address, '--port', st.secrets.proxy_credentials.port,])


    conn = psycopg2.connect(**st.secrets.psycopg2_credentials)

I have been reading the Google Cloud SQL Auth proxy docs like crazy and feel like I am running in circles at this point. Any help would be greatly appreciated. The cloud-sql-proxy file does not seem to contain any important/secret information when I open it which is why I uploaded it to GitHub but perhaps I shouldn’t? I am sure it is running something special behind the scenes that allows it to work locally but not when i deploy to streamlit cloud. You can find the repo at:

I seemed to have solved it by adding all of streamlits outbound IP addresses ( · · · · · as authorized networks in my SQL instance and then changing the psycopg2_credentials to connect to the public id address of my SQL instance rather than a manual IP address I had been setting.

I had previously been setting my own IP and port with SQL Auth proxy as such:

./cloud-sql-proxy --address --port 1234 [INSTANCE_CONNECTION_NAME]

We can’t find the IP addresses easily any longer inside of Streamlit’s documentation.

Link explaining why