Trouble with s3: Failed to open TCP connection to 169.254.169.254 due to missing secret access key

AI-generated summary

The user pfaffman encountered an error during a Discourse restore, receiving a message about failing to open a TCP connection to 169.254.169.254—a sign that the AWS SDK was attempting to retrieve instance profile credentials from the EC2 metadata service. supermathie clarified that this failure occurs because the new server lacks credentials, prompting the SDK to try fetching them from the metadata service, which only works on AWS instances. Since the server is not on AWS, this approach fails. pfaffman resolved the issue by realizing a typo in the environment variable: DISCOURSE_S3_SECRET_A CCESS (with a space) was used instead of DISCOURSE_S3_SECRET_ACCESS_KEY, causing the credentials to be ignored.

This is a standard install. These credentials work on the old server and they work on the new server using s3cmd, but when I do a discourse restore to try to get a list of backups, I get

Error retrieving instance profile credentials: Failed to open TCP connection to 169.254.169.254:80 (execution expired)

This is a sho’nuff AWS bucket. It doesn’t make any sense that it could be an issue with Discourse, but none of the other things I can come up with make sense either.

This is for what may be one of the first self-hosted forums that I’m trying to move to a new server with Ubuntu 24.04.

The AWS client is attempting to connect to the EC2 metadata service to retrieve its instance profile credentials.

If that worked, it would then use these credentials to attempt to connect to the bucket.

But, it can’t connect to the metadata service. It isn’t even trying to connect to the bucket yet, it’s failing before that.

Is this on AWS? If not, that explains why it can’t talk to the metadata service.

The new install does not see any credentials, that’s why the AWS SDK is attempting to connect to the metadata service to retrieve them.

OMG. I thought I was going crazy.

I had

DISCOURSE_S3_SECRET_ACCESS=xxx

rather than

DISCOURSE_S3_SECRET_ACCESS_KEY=xxx