Database error conection using django-mssql-backend

343 views Asked by At

I have to update an old django proyect that use django 1.8, pyodbc 3.0.10 and django-pyodbc-azure 1.8.3.0 with python 2.7.11. For the new version I need to use django 3.1.3, pyodbc 4.0.30 and django-mssql-backend 2.8.1 with python 3.9.0 the main difference is the use of django-mssql-backend 2.8.1 instead of django-pyodbc-azure 1.8.3.0, my settings.py have this configuration:

'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'dn_name',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'host\instance',
        'PORT': '1433',
        'OPTIONS': {
            'driver': 'SQL Server Native Client 11.0',
            'unicode_results': True,
        },
    },

Using the old version the connection works correctly but when I update the proyect gives me this error:

('08001', '[08001] [Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it. (10061) (SQLDriverConnect); [08001] [Microsoft][SQL Server Native Client 11.0]Login timeout expired (0); [08001] [Microsoft][SQL Server Native Client 11.0]Invalid connection string attribute (0); [08001] [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. (10061)')

For what I know I have the correct configuration. Somebody knows if I miss something?

1

There are 1 answers

0
M. Gar On

The problem was the 'PORT': '1433' parameter I use 'PORT': '' and that solve the problem