New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open server "1433D" requested by the login #330

Closed
jlvcm opened this Issue Jun 5, 2015 · 13 comments

Comments

Projects
None yet
@jlvcm

jlvcm commented Jun 5, 2015

i'm using freetds-0.91-12.git0a42888 and MSSQL server from Azure and pymssql=2.1.1

and on freetds.conf i've configured my server:

[mymssql-beta]
        host = mymssql.database.windows.net
        port = 1433
        tds version = 8.0
        client charset = UTF-8

and if i try to connect using the tsql:
tsql -S mymssql-beta -U myusername -P mypassword_ -D mydb
it works just fine, but when i try to connect using pymssql

import pymssql
conn = pymssql.connect("mymssql-beta","myusername","mypassword","mydb")

i'm get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pymssql.pyx", line 637, in pymssql.connect (pymssql.c:9508)
pymssql.OperationalError: (40532, 'Cannot open server "1433D" requested by the login.The login failed.
DB-Lib error message 20018, severity 20:
    General SQL Server error: Check messages from the SQL Server
DB-Lib error message 20002, severity 9:
    Adaptive Server connection failed')
@ezwiefel

This comment has been minimized.

ezwiefel commented Jul 26, 2015

The username requires the server name as well - so instead of "myusername" you need "myusername@mymssql-beta"

I was running into the same issue, but found the solution on https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-python-simple-ubuntu-linux/

@proftom

This comment has been minimized.

proftom commented Aug 2, 2015

had the same problem. ezwiefel's answer fixed it. thanks 👍

@acrain

This comment has been minimized.

acrain commented Aug 20, 2015

Same here. Thanks @ezwiefel. Should be better documented somewhere...

@ramiro ramiro added the docs label Oct 19, 2015

@ramiro ramiro closed this in c38e8da Nov 8, 2015

@velle

This comment has been minimized.

velle commented Sep 24, 2016

I get the same error, however the solution mentioned here (adding "@server") does not work for me.

Could you please explain me why it says "D". Why "1433D"? Is that short notation for something? And why does it say "Can not open server 1433D". Does it think that 1433/1433D is a hostname?

@divyashravanthi

This comment has been minimized.

divyashravanthi commented Oct 11, 2016

Using an mssql adapter, you might have to set an explicit option "azure: true" to the connection specifications.

@rootchina

This comment has been minimized.

rootchina commented Jan 25, 2017

ezwiefel's answer could resolve my similar issue as well. Here's the example code:

import pymssql
conn = pymssql.connect(server='yourserver.database.chinacloudapi.cn', user='yourusername@yourserver', password='yourpassword', database='AdventureWorks')

@igotmail9

This comment has been minimized.

igotmail9 commented Sep 17, 2017

Thank you Mr. ezwiefel, this worked for me

@shoaib-s

This comment has been minimized.

shoaib-s commented Feb 1, 2018

Thank you ezwiefel

The username requires the server name as well worked for me.

@Ex3v

This comment has been minimized.

Ex3v commented Jun 14, 2018

@ezwiefel you rock! 🚀 Thanks

@xsqian

This comment has been minimized.

xsqian commented Jul 19, 2018

it's good to have a work around with the ODBC connection like in @ezwiefel 's solution. I would like to see if there is any solution to use pymssql.connect()?

@xsqian

This comment has been minimized.

xsqian commented Jul 19, 2018

I am getting this error: File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824) pymssql.OperationalError: (40532, b'Cannot open server "1433D" requested by the login. The login failed.DB-Lib error message 20018, severity 20:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection faile...

@Ex3v

This comment has been minimized.

Ex3v commented Jul 19, 2018

@xsqian please dump whole exception message.

@xsqian

This comment has been minimized.

xsqian commented Jul 19, 2018

Hi @Ex3v actually @ezwiefel 's solution regarding the username worked. The username has to be in the format of "user@server". Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment