Connection Error on Local Streamlit App - Works on Streamlit Cloud

Issue Description:
I have developed a Streamlit application for helping coaches. The app works flawlessly when deployed via GitHub on Streamlit Cloud, but I encounter persistent connection issues when running it locally on my machine.

-OS: Windows 10
-Python Version: 3.10
-Streamlit Version: Latest

When I execute streamlit run in my VS terminal, the app opens in my local http://localhost:8501. I see my app. But when I press, an actionable button (e.g., “Generate”), the app runs (indicated by “RUNNING” status), but then it hangs with a “CONNECTING” message in the upper right corner. Eventually, I receive the following error:
Connection error
Is Streamlit still running? If you accidentally stopped Streamlit, just restart it in your terminal:
I get the same message every time I try to execute the app from the terminal.

Steps Taken:

  • Cleared Streamlit cache programmatically using st.cache_data.clear().
  • Cleared browser history and cache (Google Chrome).
  • Simplified button callback to isolate the issue.
  • Added logging and diagnostics to trace the problem, identifying it might be related to solver.Solve(model) in the CP-SAT solver from OR-Tools.

import streamlit as st
import pandas as pd
from ortools.sat.python import cp_model
import random
from datetime import datetime
import uuid
import subprocess
import pyarrow as pa
import logging
import os

Code Snippet:
When, I press the Generate button in the app:
if st.button(“Generate Lineup”):
model, lineup_vars = create_model(players, positions, skills)
st.session_state.lineup_df = solve_lineup_model(model, vars, players, skills, team_name)
st.session_state.lineup_generated = True,

Based on some debugging print lines, the app hangs during this function call:

Function to solve the model

def solve_lineup_model(model, vars, players, skills, team_name):

Starting to solve the model…
’, unsafe_allow_html=True)
solver = cp_model.CpSolver()
status = solver.Solve(model)
Checking on the status…
’, unsafe_allow_html=True)
if status == cp_model.OPTIMAL or status == cp_model.FEASIBLE:
code continues…
The app never gets to display the print statement - Checking on the status…


  • The issue seems to happen at the line status = solver.Solve(model), as the code never progresses beyond this point. However, since the same code/library runs in the deployed cloud app, it seems unlikely that the issue is related to the OR-Tools CP-SAT solver.
  • This function runs - and same entire python code - without issues on the Streamlit Cloud deployment via GitHub but fails locally now. Note that it used to run just fine locally a couple days ago with the same python code


  1. Has anyone encountered a similar issue with Streamlit?
  2. Could this be related to local environment configuration or some underlying resource constraint?
  3. Any other suggestions or debugging steps I should consider?

I appreciate any insights or suggestions the community can provide.