-
Link to the public app: https://magwaza-assistant-ai.streamlit.app/
-
Link to your app’s public GitHub repository: GitHub - mpho3-glitch/Demo: example · GitHub
-
Error message: streamlit.errors.StreamlitSecretNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).
Traceback:
-
Version of Streamlit: website??, Python: 3.14
"I’m getting a StreamlitSecretNotFoundError on a fresh Streamlit Cloud deployment. The app is a brand new deploy, created after deleting a previous app entirely. I’ve verified the secrets are correctly saved in the app’s Secrets panel, checked formatting and spacing multiple times, tried new API keys, and rebooted the app several times. The error still persists. Oddly, the traceback references a local Windows file path, even though the app is genuinely running on the Cloud URL, not locally. The code accesses secrets at the very top of the script, before any other logic runs, using standard syntax like st.secrets [quote, the key name, quote]. Any idea what could cause secrets to fail to load even after a full app recreation?
Hey there, thanks for sharing all those details and welcome to the Streamlit community!
Sorry you’re hitting this StreamlitSecretNotFoundError—let’s see if we can get you unstuck.
This error usually means Streamlit can’t find the key you’re trying to access in your app’s secrets, or the secrets file isn’t being loaded at all. Even if you’ve added secrets in the Cloud UI, common causes include: (1) a typo or mismatch in the key name (case-sensitive!), (2) incorrect TOML formatting (quotes, brackets, or indentation), (3) saving secrets under a section (e.g., [api]) but accessing them as a root key, or (4) a platform-side caching issue after deleting/redeploying the app. Also, if you changed your app’s GitHub repo, branch, or entrypoint, secrets may not carry over, as they’re tied to the app instance, not the codebase. There’s no built-in way to recover deleted secrets, so always keep a local backup of your secrets.toml. For more, see the official docs on secrets management and app settings.
Here’s a quick checklist:
- Double-check the key name in both your code and the Secrets panel (case and section).
- Make sure your TOML is valid—no stray quotes or indentation issues.
- If you use sections (e.g., [api]), access with st.secrets[“api”][“key”].
- Try deleting and re-adding the secrets, then reboot the app.
- If you recently changed the repo/branch/entrypoint, re-add secrets for the new app instance.
If you’re still stuck, please share a minimum reproducible example (code snippet and your secrets structure, with sensitive info redacted) so the community can help debug. Folks, feel free to jump in with your own troubleshooting tips or similar experiences!
Sources: