Application error when deploying streamlit to heroku

Hi everyone, I’m getting an error when deploying my streamlit app to heroku.

Here’s my

import streamlit as st
st.title("Hello streamlit")
st.subheader("My first streamlit app")
st.write("COVID-19 dashboard app coming soon")

Here’s my requirement.txt



mkdir -p ~/.streamlit

echo "[server]
headless = true
port = $PORT
enableCORS = false
" > ~/.streamlit/config.toml

Output for heroku log --tail

2020-08-12T05:10:50.443070+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" request_id=d8adbea5-dc86-4b83-a2f0-1c31f43f5aee fwd="" dyno= connect= service= status=503 bytes= protocol=https
2020-08-12T05:12:21.543601+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-12T05:12:30.932359+00:00 heroku[web.1]: Starting process with command `sh && streamlit run`
2020-08-12T05:12:34.530452+00:00 app[web.1]: Traceback (most recent call last):
2020-08-12T05:12:34.530483+00:00 app[web.1]: File "/app/.heroku/python/bin/streamlit", line 5, in <module>
2020-08-12T05:12:34.530650+00:00 app[web.1]: from streamlit.cli import main
2020-08-12T05:12:34.530707+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 102, in <module>
2020-08-12T05:12:34.530979+00:00 app[web.1]: from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
2020-08-12T05:12:34.531020+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 30, in <module>
2020-08-12T05:12:34.531235+00:00 app[web.1]: from streamlit import caching
2020-08-12T05:12:34.531275+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 40, in <module>
2020-08-12T05:12:34.531522+00:00 app[web.1]: from streamlit.hashing import Context
2020-08-12T05:12:34.531562+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 40, in <module>
2020-08-12T05:12:34.531782+00:00 app[web.1]: from streamlit.folder_black_list import FolderBlackList
2020-08-12T05:12:34.531821+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 39, in <module>
2020-08-12T05:12:34.532032+00:00 app[web.1]: if config.get_option("global.developmentMode"):
2020-08-12T05:12:34.532071+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 90, in get_option
2020-08-12T05:12:34.532303+00:00 app[web.1]: parse_config_file()
2020-08-12T05:12:34.532337+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 925, in parse_config_file
2020-08-12T05:12:34.533082+00:00 app[web.1]: _update_config_with_toml(file_contents, filename)
2020-08-12T05:12:34.533120+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/", line 847, in _update_config_with_toml
2020-08-12T05:12:34.533733+00:00 app[web.1]: parsed_config_file = toml.loads(raw_toml)
2020-08-12T05:12:34.533772+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/toml/", line 262, in loads
2020-08-12T05:12:34.534084+00:00 app[web.1]: original, i)
2020-08-12T05:12:34.534134+00:00 app[web.1]: toml.decoder.TomlDecodeError: Found invalid character in key name: '['. Try quoting the key name. (line 1 column 2 char 1)
2020-08-12T05:12:34.642988+00:00 heroku[web.1]: Process exited with status 1
2020-08-12T05:12:34.687483+00:00 heroku[web.1]: State changed from starting to crashed

Would really appreciate any kind of help!

just open terminal execute these commands -

  1. streamlit config show > ~/.streamlit/config.toml
  2. rm -i ~/.streamlit/config.toml

This solved it for me ^^

1 Like

I was also facing the same error and for me, it got resolved by updating the file like below:

mkdir -p ~/.streamlit/

echo "[server]
headless = true
port = $PORT
enableCORS = false
" > ~/.streamlit/config.toml

As, the file content that you have provided is missing one ‘/’ thus it is giving invalid character ‘[’ error.

Hope it helps!!