Problem description and steps to reproduce
When attempting to apply migrations to create the initial schemas, I encounter an error stating: "Adaptive Server is unavailable or does not exist." Although I am able to ping the SQL Server from my "web" container where Django is running, I am unable to establish a connection with the mssql-django library. Interestingly, I can successfully access the database using a SQL client with the same credentials. In the past I used SqlAlchemy with pymsql with the same docker setup and it worked flawlessly.
Error message/stack trace
django.db.utils.OperationalError: ('08S01', '[08S01] [FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist (20009) (SQLDriverConnect)')
Any other details that can be helpful
FROM --platform=linux/amd64/v2 ubuntu:24.04
WORKDIR /opt/
# Set environment variables
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# Poetry's configuration:
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_VIRTUALENVS_IN_PROJECT=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_VERSION=1.7.1
RUN apt-get update && apt-get install -y curl build-essential apt-transport-https gpg
# adding custom MS repository
RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
RUN curl -fsSL https://packages.microsoft.com/config/ubuntu/24.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
# install SQL Server drivers
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y python3.12 python3.12-dev python3-pip python3.12-venv unixodbc-dev unixodbc freetds-dev freetds-bin tdsodbc libpango-1.0-0 libpangoft2-1.0-0
RUN apt-get install -y iputils-ping
# Install Poetry and Dependencies
RUN pip3 install --break-system-packages --upgrade pip setuptools
ARG POETRY_VERSION=1.8.2
ENV POETRY_HOME=/opt/poetry\
PATH="${PATH}:/opt/poetry/bin"
RUN python3 -m venv ${POETRY_HOME} &&\
${POETRY_HOME}/bin/pip install poetry==${POETRY_VERSION} &&\
poetry config virtualenvs.create false
# Copy only the dependencies files to the container
COPY poetry.lock pyproject.toml /opt/
# Install project dependencies
RUN poetry install --no-root --no-interaction --no-ansi --no-dev
# Copy the rest of the application code to the container
COPY . /opt/
# Expose the port Gunicorn will listen on
EXPOSE 8000
RUN python3 /opt/zoll_app/manage.py migrate --noinput
# Run gunicorn
CMD ["python3", "/opt/zoll_app/manage.py", "runserver", "0.0.0.0:8000"]
Thanks for providing the details, I haven't tested your whole setup yet. But from the OS version, currently ODBC does not have official support for 24.04 yet. Could you try earlier versions?
Software versions
Table schema and Model No schema yet, as it is a fresh project.
Database Connection Settings
Problem description and steps to reproduce When attempting to apply migrations to create the initial schemas, I encounter an error stating: "Adaptive Server is unavailable or does not exist." Although I am able to ping the SQL Server from my "web" container where Django is running, I am unable to establish a connection with the mssql-django library. Interestingly, I can successfully access the database using a SQL client with the same credentials. In the past I used SqlAlchemy with pymsql with the same docker setup and it worked flawlessly.
Error message/stack trace
Any other details that can be helpful
Thanks for your help 🤗