question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Invalid endpoint: https://s3..amazonaws.com when initiating s3 client

See original GitHub issue

Hey, hope its not a duplicate issue but when I’m trying to initialise s3 client I sometimes get the following error:

 self.client = boto3.client("s3")
  File "/usr/local/lib/python3.6/site-packages/boto3/__init__.py", line 83, in client
    return _get_default_session().client(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/local/lib/python3.6/site-packages/botocore/session.py", line 861, in create_client
    client_config=config, api_version=api_version)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 76, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/lib/python3.6/site-packages/botocore/client.py", line 285, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/usr/local/lib/python3.6/site-packages/botocore/args.py", line 79, in get_client_args
    timeout=(new_config.connect_timeout, new_config.read_timeout))
  File "/usr/local/lib/python3.6/site-packages/botocore/endpoint.py", line 297, in create_endpoint
    raise ValueError("Invalid endpoint: %s" % endpoint_url)
ValueError: Invalid endpoint: https://s3..amazonaws.com

Any idea why it can happen?

(Versions: boto3==1.7.29, botocore==1.10.29)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
wadkarcommented, Jun 21, 2020

For those who reach this issue via search engine: export AWS_DEFAULT_REGION='<your-default-region>' should do the trick.

FWIW, it’s a workaround that will override your config settings in ~/.aws/config file.

It’s a mystery to me via boto3.client('iam') works but boto3.client('sts') won’t. I tried it with all versions of boto3 from latest 1.14.17 till 1.9.0. The boto3.client('sts') fails for all. But the code path should be same for both client calls as the error stems from the session creation code.

The culprit is endpoint_region_name variable in botocore’s session module which takes value of an empty string '', raising an exception.

🤷

2reactions
mottesen-cityworkscommented, Jun 30, 2020

For those who reach this issue via search engine: export AWS_DEFAULT_REGION='<your-default-region>' should do the trick.

FWIW, it’s a workaround that will override your config settings in ~/.aws/config file.

It’s a mystery to me via boto3.client('iam') works but boto3.client('sts') won’t. I tried it with all versions of boto3 from latest 1.14.17 till 1.9.0. The boto3.client('sts') fails for all. But the code path should be same for both client calls as the error stems from the session creation code.

The culprit is endpoint_region_name variable in botocore’s session module which takes value of an empty string '', raising an exception.

🤷

Thanks, the environment variable fix helped when getting this exception with EC2

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: Invalid endpoint: https://s3..amazonaws.com
It looks like you have an invalid region. Check your ~/.aws/config.
Read more >
ValueError Invalid endpoint https s3 amazonaws com - Edureka
When an EMR machine is trying to run a step that includes boto3 initialization it sometimes gets the following error: ValueError: Invalid ......
Read more >
Invalid Endpoint Error in AWS CLI [Solved] | bobbyhadz
The "Invalid endpoint" error occurs when the region that applies to the AWS CLI command is not set properly and most often is...
Read more >
Getting an invalid endpoint error after updating my region ...
I am trying to copy a file from my computer to AWS S3 from my command line. Invalid endpoint: https://s3..amazonaws.com I updated my...
Read more >
Troubleshoot Could not connect to endpoint URL error when I ...
Troubleshoot Could not connect to endpoint URL error when I run the sync command on S3 bucket error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found