OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Unable to Connect to Amazon Redshift Serverless from Python - Connection Timeout

  • Thread starter Thread starter Martin Østvik
  • Start date Start date
M

Martin Østvik

Guest
I've been trying to connect to my Amazon Redshift Serverless instance from Python, using the redshift_connector package, but I keep encountering a connection timeout error.

This is how I try to connect:

Code:
host="redshift-host"
database="dev"
port=5439
user="admin"
password="the-admin-password"
serverless_acct_id="my_serverless_account_id"
serverless_work_group="my_workgroup_name"

# Option 1

conn = redshift_connector.connect(

    iam=True,
    host=host,
    database=database,
    access_key_id="AWS_ACCESS_KEY_ID",
    secret_access_key="AWS_SECRET_ACCESS_KEY",
    session_token="AWS_SESSION_TOKEN",
    region="eu-north-1",
    is_serverless=True,
    serverless_acct_id=serverless_acct_id,
    serverless_work_group=serverless_work_group
)

# Option 2

conn = redshift_connector.connect(
    host=host,
    database=database,
    port=port,
    user=user,
    password=password,
)

Both of these fail with: raise OperationalError("connection time out", timeout_error) redshift_connector.error.OperationalError: ('connection time out', TimeoutError(60, 'Operation timed out'))

Here are the details of my setup and what I've tried so far:

What I've Checked:

  • Public Accessibility: Confirmed that the Redshift serverless endpoint is set to publicly accessible.
  • Security Groups: Ensured that the security group allows inbound traffic on port 5439 from 0.0.0.0/0.
  • Network ACLs: Verified that the Network ACLs for the subnet do not block inbound or outbound traffic on port 5439.
  • Route Table: Checked that the subnet route table includes a route to an Internet Gateway (0.0.0.0/0 -> igw-XXXXXXXX). Local Firewall: No firewall rules blocking out outbound traffic blocking on port 5439.

To me it seems like everything should be set up correctly and I should be able to connect. However I still keep getting timeout error. What am I doing wrong?

I tried allowing all traffic in the security group and setting publicly accessible to True. I expected to be able to connect, but it is timing out.
<p>I've been trying to connect to my Amazon Redshift Serverless instance from Python, using the <a href="https://pypi.org/project/redshift-connector/" rel="nofollow noreferrer">redshift_connector</a> package, but I keep encountering a connection timeout error.</p>
<p>This is how I try to connect:</p>
<pre class="lang-py prettyprint-override"><code>
host="redshift-host"
database="dev"
port=5439
user="admin"
password="the-admin-password"
serverless_acct_id="my_serverless_account_id"
serverless_work_group="my_workgroup_name"

# Option 1

conn = redshift_connector.connect(

iam=True,
host=host,
database=database,
access_key_id="AWS_ACCESS_KEY_ID",
secret_access_key="AWS_SECRET_ACCESS_KEY",
session_token="AWS_SESSION_TOKEN",
region="eu-north-1",
is_serverless=True,
serverless_acct_id=serverless_acct_id,
serverless_work_group=serverless_work_group
)

# Option 2

conn = redshift_connector.connect(
host=host,
database=database,
port=port,
user=user,
password=password,
)
</code></pre>
<p>Both of these fail with:
<code> raise OperationalError("connection time out", timeout_error) redshift_connector.error.OperationalError: ('connection time out', TimeoutError(60, 'Operation timed out'))</code></p>
<p>Here are the details of my setup and what I've tried so far:</p>
<p>What I've Checked:</p>
<ul>
<li>Public Accessibility: Confirmed that the Redshift serverless endpoint is set to publicly accessible.</li>
<li>Security Groups: Ensured that the security group allows inbound traffic on port 5439 from 0.0.0.0/0.</li>
<li>Network ACLs: Verified that the Network ACLs for the subnet do not block inbound or outbound traffic on port 5439.</li>
<li>Route Table: Checked that the subnet route table includes a route to an Internet Gateway (0.0.0.0/0 -> igw-XXXXXXXX).
Local Firewall: No firewall rules blocking out outbound traffic blocking on port 5439.</li>
</ul>
<p>To me it seems like everything should be set up correctly and I should be able to connect. However I still keep getting timeout error. What am I doing wrong?</p>
<p>I tried allowing all traffic in the security group and setting publicly accessible to <code>True</code>. I expected to be able to connect, but it is timing out.</p>
 
Top