ESSolutions / django-mssql-backend

Django backend for Microsoft SQL Server
https://pypi.org/project/django-mssql-backend/
BSD 3-Clause "New" or "Revised" License
147 stars 51 forks source link

Error [HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired #110

Open legioz opened 3 years ago

legioz commented 3 years ago

image

'HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)'

I am getting the error above, I am using Django 3.0.5 with django-mssql-backend 2.8.1

My config on settings.py is:


DATABASES = {

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': config('MYSQL_DEFAULT_DB'),
        'USER': config('MYSQL_DEFAULT_USER'),
        'PASSWORD': config('MYSQL_DEFAULT_PASS'),
        'HOST': config('MYSQL_DEFAULT_HOST'),
        'PORT': config('MYSQL_DEFAULT_PORT'),
        'OPTIONS': {
            'init_command': "SET sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO'"
        },
    },

      'db2': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': config('DB2_DB'),
        'HOST': config('DB2_SERVER'),
        'PORT': config('DB2_PORT'),
        'USER': config('DB2_USER'),
        'PASSWORD': config('DB2_PASS'),
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server',
        },
    },
.
.
.

The port DB2_PORT variable cannot be an empty string.

All variables are beeing passed correctly and I can connect directly to DB2 using others MSSQL clients

[

interpeix commented 3 years ago

@luizfelipevbll we are facing the same issue on a serverless database, we thought that's related with auto-pause feature, but after digging a bit more we are less confident that is the issue. Any help would be apreciated.

ibrahimduran commented 3 years ago

I don't have much experience with SQL Server but in my case issue was caused by ODBC drivers (testing with sqlcmd failed, mssql-cli from pip worked) and I had to create a data source in /etc/odbc.ini and connect through DSN. Here's a detailed explanation: https://stackoverflow.com/a/48367250

KhushbooKaul2002 commented 2 years ago

@luizfelipevbll : did you find a solution to the problem you were facing because I am also facing the same issue trying to connect my django app with the ms sql server.

nickolasgcb commented 2 years ago

I got this same issue, how you solved it?