title: Why connection to Redshift from Python sometimes times out?
body: <p>I'm connecting Redshift through Python from PC, Python from Lambda and SQL Workbench.
  SQL Workbech always connects without any issues.
  Both PC and Lambda often work correctly, but sometimes they can't connect - it looks like connection is waiting for Redshift to accept request, just nothing happens until, for ex. Lambda times out.</p>
  <p>There's no log in run, no feedback information, nothing in redshift logs I can find about it.
  I can fix every single run manually by connecting in Workbench, while the script is waiting for connection - it apparently refreshes something, allowing Python to connect and work properly.
  What is the reason for this and how can I fix it?</p>
  <p>Here's my connection:</p>
  <pre><code>conn = psycopg2.connect(
      host=host,
      database=db,
      user=user,
      password=pwd,
      port=port
  )
  </code></pre>
  <p>I went through several questions regarding connections like:</p>
  <p><a href="https://stackoverflow.com/questions/44112128/aws-lambda-times-out-connecting-to-redshift">AWS Lambda times out connecting to RedShift</a></p>
  <p><a href="https://stackoverflow.com/questions/65788920/aws-serverless-lambda-times-out-while-connecting-to-redshift">AWS Serverless lambda times out while connecting to redshift</a></p>
  <p><a href="https://stackoverflow.com/questions/53231849/python-socket-windows-10-connection-times-out">python socket Windows 10 connection times out</a></p>
  <p>but nothing looks like its related to my issue.</p>