a month ago
I'm experiencing persistent 502 Bad Gateway errors on my deployed service, despite it showing as ACTIVE. Below are the key details of the issue:
Service Information
Service Name:
ocr-whisper-api
Service ID:
[please refer to image_f95d7b.png or image_04b2eb.png for ID, e.g., ad7d449]
Public URL: https://ocr-whisper-api-production-03e9.up.railway.app
Deployment Region: Southeast Asia (Singapore)
Deployment Status
Status: ACTIVE
Logs confirm:
INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000
Troubleshooting Steps Taken
Simplified
main.py
to return only:return {"message": "Hello from Railway"}
Removed all model loading, database connections, and startup tasks.
Updated
Dockerfile
to usegunicorn
:CMD ["gunicorn", "--bind", "0.0.0.0:$PORT", "--worker-class", "uvicorn.workers.UvicornWorker", "--workers", "1", "main:app"]
Installed all necessary APT and pip dependencies (including for PyMuPDF, paddleocr, etc.).
Resource usage is well below the 8GB limit.
No
Start Command
override is set in Railway settings.Health check path
/
is functional inmain.py
.No firewall or origin restrictions configured.
Current Symptoms
All HTTP requests to
/
,/docs
,/favicon.ico
return 502 Bad Gateway.HTTP logs show response times as low as 1ms, suggesting the request may not reach the container.
No errors appear in the deploy logs.
The same service worked properly before with similar settings.
Request
Please help check your internal network or container logs to diagnose why requests to this service return 502 errors, despite the app running successfully on port 8000.
5 Replies
error
Can i see the Dockerfile?Curious how the full thing looks
a month ago
FROM python:3.11-buster
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libharfbuzz0b \
libfreetype6 \
libfontconfig1 \
libjpeg62-turbo \
libpng16-16 \
zlib1g \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV PORT 8000
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:$PORT", "--worker-class", "uvicorn.workers.UvicornWorker", "--workers", "1", "main:app"]
mollie028
FROM python:3.11-busterWORKDIR /appRUN apt-get update && \apt-get install -y --no-install-recommends \libharfbuzz0b \libfreetype6 \libfontconfig1 \libjpeg62-turbo \libpng16-16 \zlib1g \&& rm -rf /var/lib/apt/lists/*COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .ENV PORT 8000EXPOSE 8000CMD ["gunicorn", "--bind", "0.0.0.0:$PORT", "--worker-class", "uvicorn.workers.UvicornWorker", "--workers", "1", "main:app"]
a month ago
Can you go into deployments and check if the application is in a crash loop or something like how old the latest deployment is ?
Then could you remove the Health check from railway dashboard ? not from your code
24 days ago
i have develop app in fast api like book translator if i can translate large file face this issue how to solve this tell me about ?
error on processing progresss ?
Progress update received: {type: 'progress', stage: 'Translating paragraph 245 of 470...', progress: 51, message: 'Translating paragraph 245 of 470...'} index-B25U8tBm.js:47 WebSocket message received: {"type":"progress","stage":"Translating paragraph 246 of 470...","progress":51,"message":"Translating paragraph 246 of 470..."} index-B25U8tBm.js:53 Progress update received: {type: 'progress', stage: 'Translating paragraph 246 of 470...', progress: 51, message: 'Translating paragraph 246 of 470...'}message: "Translating paragraph 246 of 470..."progress: 51stage: "Translating paragraph 246 of 470..."type: "progress"[[Prototype]]: Object book-translator-ui.vercel.app/:1 Access to XMLHttpRequest at 'https://exciting-stillness-venv.up.railway.app/api/translate' from origin 'https://book-translator-ui.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error index-B25U8tBm.js:47 Translation error: F {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} translateDocument @ index-B25U8tBm.js:47 await in translateDocument z @ index-B25U8tBm.js:53 Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:53 Translation error: F {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} z @ index-B25U8tBm.js:53 await in z Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:44 POST https://exciting-stillness-venv.up.railway.app/api/translate net::ERR_FAILED 502 (Bad Gateway) (anonymous) @ index-B25U8tBm.js:44 xhr @ index-B25U8tBm.js:44 Lc @ index-B25U8tBm.js:46 _request @ index-B25U8tBm.js:47 request @ index-B25U8tBm.js:46 (anonymous) @ index-B25U8tBm.js:47 (anonymous) @ index-B25U8tBm.js:42 translateDocument @ index-B25U8tBm.js:47 z @ index-B25U8tBm.js:53 Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:47 WebSocket connection closed 1005 index-B25U8tBm.js:47 Scheduling reconnection attempt in 1000ms index-B25U8tBm.js:47 Attempting to reconnect... index-B25U8tBm.js:47 Attempting WebSocket connection to: wss://exciting-stillness-venv.up.railway.app/ws/to3j68
meatitd11
i have develop app in fast api like book translator if i can translate large file face this issue how to solve this tell me about ?error on processing progresss ?Progress update received: {type: 'progress', stage: 'Translating paragraph 245 of 470...', progress: 51, message: 'Translating paragraph 245 of 470...'} index-B25U8tBm.js:47 WebSocket message received: {"type":"progress","stage":"Translating paragraph 246 of 470...","progress":51,"message":"Translating paragraph 246 of 470..."} index-B25U8tBm.js:53 Progress update received: {type: 'progress', stage: 'Translating paragraph 246 of 470...', progress: 51, message: 'Translating paragraph 246 of 470...'}message: "Translating paragraph 246 of 470..."progress: 51stage: "Translating paragraph 246 of 470..."type: "progress"[[Prototype]]: Object book-translator-ui.vercel.app/:1 Access to XMLHttpRequest at 'https://exciting-stillness-venv.up.railway.app/api/translate' from origin 'https://book-translator-ui.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error index-B25U8tBm.js:47 Translation error: F {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} translateDocument @ index-B25U8tBm.js:47 await in translateDocument z @ index-B25U8tBm.js:53 Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:53 Translation error: F {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} z @ index-B25U8tBm.js:53 await in z Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:44 POST https://exciting-stillness-venv.up.railway.app/api/translate net::ERR_FAILED 502 (Bad Gateway) (anonymous) @ index-B25U8tBm.js:44 xhr @ index-B25U8tBm.js:44 Lc @ index-B25U8tBm.js:46 _request @ index-B25U8tBm.js:47 request @ index-B25U8tBm.js:46 (anonymous) @ index-B25U8tBm.js:47 (anonymous) @ index-B25U8tBm.js:42 translateDocument @ index-B25U8tBm.js:47 z @ index-B25U8tBm.js:53 Ym @ index-B25U8tBm.js:37 Xm @ index-B25U8tBm.js:37 Gm @ index-B25U8tBm.js:37 bu @ index-B25U8tBm.js:37 nd @ index-B25U8tBm.js:37 (anonymous) @ index-B25U8tBm.js:37 Ls @ index-B25U8tBm.js:40 Np @ index-B25U8tBm.js:37 vl @ index-B25U8tBm.js:37 as @ index-B25U8tBm.js:37 mh @ index-B25U8tBm.js:37Understand this error index-B25U8tBm.js:47 WebSocket connection closed 1005 index-B25U8tBm.js:47 Scheduling reconnection attempt in 1000ms index-B25U8tBm.js:47 Attempting to reconnect... index-B25U8tBm.js:47 Attempting WebSocket connection to: wss://exciting-stillness-venv.up.railway.app/ws/to3j68
24 days ago
If this is a completely different issue then create a separate thread about it. to me this doesn't look like what you described in your main post.
Status changed to Solved chandrika • 24 days ago