Yes this sounds like a configuration issue , the exact fox depends on where you deployed it .
Streamlit system usually uses its own secret systems not .env files .
The local .env files don't go with you when you do the deployment. Streamlit has its own secret manager
# You configure this in Streamlit Cloud dashboard
# Settings → Secrets → paste this in
OPENAI_API_KEY = "sk-your-key-here"
DATABASE_URL = "postgresql://..."
[database]
host = "localhost"
port = 5432
Then in your code, access it like this:
import streamlit as st
# Access flat secrets
api_key = st.secrets["OPENAI_API_KEY"]
# Access nested secrets
db_host = st.secrets["database"]["host"]
# Or use it like a dict
db_config = st.secrets["database"]