'OperationalError: 250003: Failed to get the response. Hanging? method: post

I am trying to connect to snowflake using my login credentials. I'm using the following code:

snowflake.connector.connect(
    user="<my_user_name>",
    password="<my_password>",
    account="<my_account_name_with_region_and_cloud>"
    )

When I try to run the above code, I'm getting the following error:

OperationalError: 250003: Failed to get the response. Hanging? method: post, url: https://hm53485.us-east-2.aws.snowflakecomputing.com:443/session/v1/login-request?request_id=fcfdd77a-11ff-4956-9ed8-bcc332c5989a&databaseName=S3_DB&schemaName=PUBLIC&warehouse=COMPUTE_WH&request_guid=b9fdb5c9-81cb-4ecb-8d20-abef44249bbf

I'm sure that all my packages are up to date. I'm using python 3.6.4 and the latest snowflake_connector_python.

I'm currently on us-east-2 location in aws.

Can someone please help me out on this????



Solution 1:[1]

Just Give your account name in the account .We dont need the region and full URL.
Please check below .

----------------------------------------------------------------------
import snowflake.connector


PASSWORD = '*******'
USER = '<USERNAME>'
ACCOUNT = 'SFCSUPPORT'
WAREHOUSE = '<WHNAME>'
DATABASE = '<DBNAME>'
SCHEMA = 'PUBLIC'

print("Connecting...")
# -- (> ------------------- SECTION=connect_to_snowflake --------------------
con = snowflake.connector.connect(
  user=USER,
  password=PASSWORD,
  account=ACCOUNT,
  warehouse=WAREHOUSE,
  database=DATABASE,
  schema=SCHEMA
)


con.cursor().execute("USE WAREHOUSE " + WAREHOUSE)
con.cursor().execute("USE DATABASE " + DATABASE)
#con.cursor().execute("USE SCHEMA INFORMATION_SCHEMA")


try:
    result = con.cursor().execute("Select * from <TABLE>")
    result_list = result.fetchall()
    print(result_list)

finally:
    con.cursor().close()
con.cursor().close()

Solution 2:[2]

I'm using sqlalchemy, which you can install via pip:

pip install SQLAlchemy

https://docs.snowflake.net/manuals/user-guide/sqlalchemy.html

Here's what I have at the beginning of my notebook:

import snowflake.connector
import pandas as pd
from sqlalchemy import create_engine
from snowflake.sqlalchemy import URL

url = URL(
    account = 'xxxxxxxx.east-us-2.azure',
    user = 'xxxxxxxx',
    password = 'xxxxxxxx',
    database = 'xxxxxxxx',
    schema = 'xxxxxxxx',
    warehouse = 'xxxxxxxx',
    role='xxxxxxxx'
)

engine = create_engine(url)
connection = engine.connect()

query = '''
    select 1 AS VAL;
'''

df = pd.read_sql(query, connection)

df

Solution 3:[3]

I was getting a similar error. Tried few things like making sure the account name is correct as per https://docs.snowflake.com/en/user-guide/admin-account-identifier.html. The account name depends on the region in which your snowflake account is located. Note that some of the cloud regions need a cloud provider name at the end and some do it.

But it didn't help fix the issue I was facing. For me, it turned out to be a proxy issue. I was trying to connect from a corporate network with a proxy and it was blocking the connection to Snowflake. Whitelisting the snowflake URL in proxy fixed the issue for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ankur Srivastava
Solution 2 Trevor
Solution 3 Mithun Manohar