Getting ODBC error while deploy python fastapi in render, any one please give me a solution

Hi there,

It doesn’t look like your service has the correct configuration to connect to an SQL Server database.

Regards,

Thanks for your reply , In local its working fine but while host api in render getting such error… this there any solution for that …
dockerfile
FROM python:3.9-slim
ENV ACCEPT_EULA=Y
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update &&
apt-get install -y curl apt-transport-https gnupg2 &&
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - &&
curl https://packages.microsoft.com/config/debian/10/prod.list | tee /etc/apt/sources.list.d/msprod.list &&
apt-get update &&
apt-get install -y msodbcsql17 unixodbc-dev &&
apt-get clean &&
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY . .
RUN pip install -r requirements.txt

EXPOSE 80

CMD [“uvicorn”, “app.main:app”, “–host”, “0.0.0.0”, “–port”, “80”] this is my docker file , Is there any configation error in this

Hi there,

Hmm, it looks like you are using Debian 10 (buster) but I believe python:3.9-slim uses Debian 12 (bookworm) as its base image, not Debian 10. I think you need to install the correct ODBC drivers.

I would also check if you need to add your Render service’s outbound IP addresses to an allow list on your SQL Server.

Regards,

Keith
Render Support, UTC+10 :australia:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.