How to make streamlit run on codespaces?

Been struggling with this for a few hours now :smiling_face_with_tear:

Streamlit opens but doesn’t load any apps including streamlit hello

@robmarkcole are you still able to run streamlit in codespaces?

Hi, I had the same issue. I have solved this problem using this solution.

streamlit hello --server.enableCORS false --server.enableXsrfProtection false


Hi @fhtsibuya, welcome to the community and thanks for your solution!! :wave: :partying_face:

I’ve created a repo that includes the command line config options in a config.toml, to avoid typing them each time you run an app:


Nice, thanks @fhtsibuya! :smiley:

@snehankekre good idea having it in the config, didn’t realize that. Do you know if it’s possible to have multiple terminal commands [in devcontainer] on launch?

I want to have both pip install reqs and streamlit run with the server commands instead of having it be in config.toml. This is because I have deployed an app via github and want --server.enableCORS false --server.enableXsrfProtection false only when developing in codespaces to get it to display and not when deployed

@batman It is possible: devcontainer.json reference

Depending on your use-case, you can either use postCreateCommand or postStartCommand to run multiple commands, if each command is separated by &&. For example

"postStartCommand": "apt-get install -y curl && pip install -r requirements.txt",

Or if you have a ton of commands to run, store them in a .sh script, copy the script to the container, and run the bash script via the postStartCommand.

1 Like

Brilliant, thank you! :smiley:

And btw I just tried running your repo in a code space and it gets stuck on the please wait screen again :sweat_smile: I guess something may have changed

I just noticed that too :sweat_smile: The behavior doesn’t appear to be deterministic / reliable. If you wait for a few minutes after the container starts to run streamlit hello or streamlit run, it works as expected. If you run the app immediately, it seems to get stuck on the please wait screen.

I also observed that refreshing the page or restarting the app can sometimes get rid of the please wait screen.

1 Like

Oh wow that’s very weird :joy: thank you for that tip, I’ve really been struggling to get this working lol

And refreshing hasn’t worked for me but maybe it’s because I always run it immediately. Will try waiting a little first, hopefully it works! Thanks again :smile:

@snehankekre were you able to use codespaces again? I haven’t been able to get it to work (at all lol)

I tried --server.enableWebsocketCompression=false as well

@batman I did just get it running again by launching codespaces from my repo:

However, it isn’t reliable. I had to wait a full minute after streamlit hello for the Please Wait ... message to go away and for the app to work. :confused:

1 Like

Thank you for checking again @snehankekre! I wonder whether it’s the server region (Europe) that’s causing a problem for me

Also, I don’t know whether it’s related but recently my app deployed via heroku stays on the “please wait…” screen for so much longer than it’s used to. Do you think it could be a similar issue? Running 1.10.0

Update: just tried launching the heroku app, it took about 6-7 minutes

I haven’t deployed to Heroku yet, so I have no comments :sweat_smile: I’ll defer to others in the community.

1 Like

If you are running in Codespaces you may also need to change the visibility of port: 8501 to “public”. VSCode has a tab for ports and you will have 3 ports open.

Good news! Streamlit Community Cloud just published an update to automate creating a codespace in GitHub. You can either:

  1. Fork and deploy the Streamlit Hello app and jump into a codespace
  2. Fork and deploy a copy of a public app and jump into a codespace
  3. Create a codespace for any app you’ve deployed on Streamlit Community Cloud

Happy Streamlit-ing! :balloon:

Is there any chance that codespace would not show the simple browser when repository is private? Cuz I couldn’t make it to open preview on codespace, but app work on the other tab of the browser, although I want to see the changes instantly without committing each time.

Check your repository to make sure the .devcontainer/devcontainer.json file got correctly added to your repository. That is the magic sauce that makes it all work. If you do not see that file, you can manually add it and restart your codespace.

You can see it as an example in in this example app repo.

Hi @mathcatsand , just wanted to point out that I’m having some issues w/ timeout using the new system of deploying streamlit w/ an attached GH Codespace on this repo. I put additional details on this report, but can’t seem to figure out why everything I try times out now. Any suggestions?

It looks like on the other thread that you determined there was an issue with your ISP? Connection reliability can certainly have some unintended consequences. Let me know if I’ve misunderstood.

1 Like