# 'mssql' (also tried 'sql\_server.pyodbc) isn't an available database backend or couldn't be imported

**URL:** <https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808>\
**Category:** Mystery Errors\
**Created:** [October 26, 2023, 10:42pm UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808 "2023-10-26T22:42:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabi66](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/fabi66/32/16648_2.png) [@Fabi66](https://forum.djangoproject.com/u/Fabi66)\
**Post date:** [October 26, 2023, 10:42pm UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808/1 "2023-10-26T22:42:41Z")

</div>

I have been all over the Internet and read, as well as tried, every post and solution I could find. I cannot find a way to connect to SQL Server 2019.

I have installed, uninstalled, reinstalled: mssql-django, django-pyodbc-azure, django-mssql-backend. I’ve tried using one, two and all three at the same time. Nothing works.

I feels like it should be so simple. Setting up and testing a project with a local installation of SQL Server using Windows Default login.

With pyodbc and mssql-django installed (my latest iteration):  
settings.py  
…  
DATABASES = {  
‘default’: {  
‘ENGINE’: ‘mssql’,  
‘NAME’: ‘mytestdb’,  
‘HOST’: ‘thisPC-\MSSQLSERVER01’,  
‘PORT’:‘’,  
‘OPTIONS’: {  
‘driver’: ‘ODBC Driver 17 for SQL Server’,  
‘isolation\_level’: ‘READ UNCOMMITTED’,  
},  
}  
}…

when I run _python manage.py makemigrations TestApp_ I get a host of errors:  
…ModuleNotFoundError: No module named ‘mssql’…  
…django.core.exceptions.ImproperlyConfigured: ‘mssql’ isn’t an available database backend or couldn’t be imported…

I don’t know what to try next. I’m at a loss for ideas.

---

<div class="post-metadata">

**Author:** ![sesambrein83](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sesambrein83/32/19036_2.png) [@sesambrein83](https://forum.djangoproject.com/u/sesambrein83)\
**Post date:** [February 7, 2024, 7:33pm UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808/2 "2024-02-07T19:33:00Z")

</div>

Hey fabi66,

I’m running in the same issue. But for some reasons it works on my laptop, but doesnt work on the windows server.

Did you find the cause of your issue?

---

<div class="post-metadata">

**Author:** ![Fabi66](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/fabi66/32/16648_2.png) [@Fabi66](https://forum.djangoproject.com/u/Fabi66)\
**Post date:** [February 8, 2024, 12:55am UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808/3 "2024-02-08T00:55:58Z")

</div>

I did not find the answer. I continued exploring Django with other database platforms. But ultimately I need something that works seamlessly with SQL Server

---

<div class="post-metadata">

**Author:** ![pglu127](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pglu127/32/19039_2.png) [@pglu127](https://forum.djangoproject.com/u/pglu127)\
**Post date:** [February 8, 2024, 9:17am UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808/4 "2024-02-08T09:17:31Z")

</div>

Have you tried using mssql-django with settings:

```auto
DATABASES = {
    "default": {
        "ENGINE": "mssql",
        "NAME": "mytestdb",
        "HOST": "thisPC-\MSSQLSERVER01"
    }
}

```

---

<div class="post-metadata">

**Author:** ![TannerBadey](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/tannerbadey/32/32317_2.png) [@TannerBadey](https://forum.djangoproject.com/u/TannerBadey)\
**Post date:** [April 29, 2026, 4:27pm UTC](https://forum.djangoproject.com/t/mssql-also-tried-sql-server-pyodbc-isnt-an-available-database-backend-or-couldnt-be-imported/24808/5 "2026-04-29T16:27:07Z")

</div>

I had this exact same issue and there is NOTHING online that fixed it until I finally, FINALLY, discovered the source of the issue on my own.

I don’t know if this is the same problem everyone with this issue is running into, but I have not seen a SINGLE mention of it in any online discussion, package documentation, or thread ANYWHERE.

The cause of this issue? (for me at least):

At some poin the naming convention of the top-level folder that gets installed by the ‘mssql’ package was changed. Y’know the thing that the entire program depends on to find the package? It was renamed from ‘mssql’ to ‘MsSql’, and yes, it breaks everything and no, nothing else was changed. Even within the package itself it expects ‘mssql’, not ‘MsSql’. and yes, Python treats these as two entirely different things.

If you’re working in a virtual environment (I am, so idk if this is any different if you aren’t), go into the Lib\site-packages subfolder and look for your ‘mssql’ package. If you instead find a package named ‘MsSql’, BINGO. There’s your problem. Change that back to ‘mssql’ and, if everything else is correctly set up, you’re good to go.

I hope this can save someone from the WEEKS of utter pain that this caused me.
