snowflake.connector.errors.OperationalError: 250003: Failed to get the response

I am trying to set up a connection with Snowflake from Python using an account which is not MFA enabled, but the connection is not made. I have attached the code and logs.

from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL
from sqlalchemy.orm import sessionmaker

# # create connection object wih the
# # Bridg provided snowflake connection details provided
sf_engine = create_engine(URL(
         account='xxxx',
         user='xxx',
         password='xxxx',
         database='xxx',
         schema='xxx',
         warehouse='xxx',
         role='xxx',
))
Session = sessionmaker(bind=sf_engine, autocommit=False)
session = Session()
results = session.execute("desc view xxx.xxx.TRANSACTION;")
print(results)
/opt/anaconda3/bin/python /Users/jpriyad/Documents/pythonProject/connect/snow.py
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1014, in __authenticate
    auth.authenticate(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/auth.py", line 257, in authenticate
    ret = self._rest._post_request(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 700, in _post_request
    ret = self.fetch(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 790, in fetch
    ret = self._request_exec_wrapper(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 912, in _request_exec_wrapper
    raise e
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 844, in _request_exec_wrapper
    self._handle_unknown_error(method, full_url, headers, data, conn)
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/network.py", line 944, in _handle_unknown_error
    Error.errorhandler_wrapper(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 269, in errorhandler_wrapper
    handed_over = Error.hand_to_other_handler(
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 327, in hand_to_other_handler
    connection.errorhandler(connection, cursor, error_class, error_value)
  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/errors.py", line 203, in default_errorhandler
    raise error_class(
snowflake.connector.errors.OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://xxxx.snowflakecomputing.com:443/session/v1/login-request?request_id=828cc997-d9a1-4d29-b70f-4dab2045d18f&databaseName=xxx&schemaName=xxx&warehouse=xxx&roleName=xxx&request_guid=xxxx

During handling of the above exception, another exception occurred:


  File "/opt/anaconda3/lib/python3.8/site-packages/snowflake/connector/auth_by_plugin.py", line 117, in handle_timeout
    raise OperationalError(
sqlalchemy.exc.OperationalError: (snowflake.connector.errors.OperationalError) 250001: Could not connect to Snowflake backend after 0 attempt(s).Aborting
(Background on this error at: https://sqlalche.me/e/14/e3q8)

Process finished with exit code 1

Upvotes: 7

Views: 20683

Answers (2)

tharun
tharun

Reputation: 11

Yes i agree with the above method , for account identifier but if you facing same issues while using snowpark sessions api in instead of python connector

  1. Make sure your on python 3.8(environment)(it may change later check in the adjacent link) and install necessary packages Go here for detailed environment set up in anaconda
  2. Connection string should look like this
from snowflake.snowpark import Session
connection_parameters = {
    "user": "txxxxn",
    "account": "xxx.yyyy.azure",
    "password": "xxx",
    "role": "ACCOUNTADMIN",
    "warehouse": "xxxx",
    "database": "xxxx",
    "schema": "xxxx"}
test_session = Session.builder.configs(connection_parameters).create()
print('connected')

Note:-

  1. Warehouse,database,schema,admin are not necessary but if you decide to use them make sure , their case matches their actual counterparts in your snowflake account.
  2. I don't know why but don't use the snowpark sessions connection string provided in snowflake official documentation it didn't work for me(take this with a grain of salt they might patch it up later (post time = 10-10-2022))

Upvotes: 1

Mukul Kumar
Mukul Kumar

Reputation: 724

I was facing the same issue for awhile. It took me a long time to debug it.

Solution:

recheck the credential you are passing in account.

Wrong credential => account = 'xyz.us-east-1.snowflakecomputing.com'

correct credential => account = 'xyz.us-east-1'

Here us-east-1 is AWS region. It can be different for you.

Basically, don't pass snowflakecomputing.com in the account credential.

Upvotes: 16

Related Questions