Streamlit app hit by 502 error

sandman2412
HOBBY

15 days ago

I've been trying to deploy a Streamlit app from a Docker container for several hours now only to be hit by a 502 Error:

requestId:
"pfcXMJG5SX6HfAr80-QtfA"
timestamp:
"2025-08-14T16:47:57.562384242Z"
method:
"GET"
path:
"/"
host:
"lumon-fund-bot-production.up.railway.app"
httpStatus:
502
upstreamProto:
""
downstreamProto:
"HTTP/2.0"
responseDetails:
"Retried single replica"
totalDuration:
146
upstreamAddress:
""
clientUa:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
upstreamRqDuration:
4
txBytes:
4682
rxBytes:
937
srcIp:
"152.37.80.22"
edgeRegion:
"europe-west4-drams3a"
upstreamErrors:
"[{"deploymentInstanceID":"66cf260a-e6fc-43ff-b66b-d00e43686e91","duration":0,"error":"connection refused"},{"deploymentInstanceID":"66cf260a-e6fc-43ff-b66b-d00e43686e91","duration":0,"error":"connection refused"},{"deploymentInstanceID":"66cf260a-e6fc-43ff-b66b-d00e43686e91","duration":4,"error":"connection refused"}]"

My Dockerfile is below:

FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    rsync \
 && rm -rf /var/lib/apt/lists/*

# Install Python dependencies first
COPY docling/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy all project files
COPY . .



ARG PORT=8080
EXPOSE ${PORT}

CMD streamlit run /app/docling/5-chat.py --server.address 0.0.0.0 --server.port $PORT

My railway.toml file is:

[build]
builder = "dockerfile"
dockerfilePath = "Dockerfile"

[deploy]
healthcheckPath = "/"
healthcheckTimeout = 300
restartPolicyType = "on_failure"

I'm using a Railway volume as I need to access data from persistent storage.

Can someone help here?

$10 Bounty

0 Replies

sandman2412
HOBBY

15 days ago

Here are the deploy logs which don't show any error:

Here's my Deploy logs:

Mounting volume on: /var/lib/containers/railwayapp/bind-mounts/66cf260a-e6fc-43ff-b66b-d00e43686e91/vol_r7rq2uik7u834q8n

Starting Container



Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.





  You can now view your Streamlit app in your browser.



  URL: http://0.0.0.0:8080

14 days ago

Hey @Sandip, have you checked the docs for possible solutions? Especially checking if the port is set correctly in the public networking section.


sandman2412
HOBBY

14 days ago

@uxuz Thanks, I managed to fix it by changing the custom port in the Networking section of settings! Now, however, I face a different problem: my app connects to a sqlite-like DB (called LanceDB) which I've copied over in the Dockerfile. I'm using a Railway Volume mounted at /data and copying over the data/ folder from my repo like so:

```RUN echo '#!/bin/bash\n\
if [ ! -f "/data/.initialized" ]; then\n\
echo "Copying database to persistent volume…"\n\
cp -r /app/data/* /data/ 2>/dev/null || true\n\
touch /data/.initialized\n\
fi\n\
exec streamlit run /app/docling/5-chat.py --server.address 0.0.0.0 --server.port ${PORT} --server.headless true\n\
' > /start.sh && chmod +x /start.sh

However, the app is unable to find the db files:

Failed to connect to database at /data/lancedb: Table 'portfolio' was not found

Make sure the database has been initialized by running the pipeline steps 1-3```

I'm unfortunately finding Railway quite opaque as it does not surface the Docker logs making it difficult to debug!


sandman2412
HOBBY

14 days ago

What I'm missing is direct SSH access to the container


14 days ago

railway ssh