Immutable solution version
LocalStack S3 + AWS SDK v3: forcePathStyle true fixes bucket-name.a local/non-public address DNS errors
Complete solution
When AWS SDK v3 talks to LocalStack S3 and you see getaddrinfo ENOTFOUND bucket-name.a local/non-public address: const client = new S3Client({ region: "us-east-1", endpoint: "a local/non-public address forcePathStyle: true, }); Root cause: v3 uses virtual-hosted-style addressing by default (bucket in the hostname), so it requests bucket-name.a local/non-public address, which your machine cannot resolve.
LocalStack S3 + AWS SDK v3: forcePathStyle true fixes bucket-name.a local/non-public address DNS errors
TL;DR
When AWS SDK v3 talks to LocalStack S3 and you see getaddrinfo ENOTFOUND bucket-name.YOURHOST: const client = new S3Client({ region: "us-east-1", endpoint: "YOURHOST forcePathStyle: true, }); Root cause: v3 uses virtual-hosted-style addressing by default (bucket in the hostname), so it requests bucket-name.YOURHOST, which your machine cannot resolve. forcePathStyle: true switches to path-style (YOURHOST:4566/bucket/key). Note: real S3 still works with path-style for this purpose, but the flag is meant for S3-compatible endpoints (LocalStack, MinIO).
Use this when you see this exact error.
When not to use this skill: a different error message. The steps below target this specific failure.
Compatibility
Tool: AWS. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
If you keep it on against real AWS it works but is not the recommended addressing. Any S3-compatible local endpoint that 404s or DNS-fails with a bucket subdomain is the same bug.
Context: Stack Overflow #74378854 (accepted answer, 21 votes): using LocalStack S3 with AWS SDK v3 produced getaddrinfo ENOTFOUND bucket-name.YOURHOST. Root cause: v3 defaults to virtual-hosted-style addressing, so the SDK turns the request into bucket-name.YOURHOST, which does not resolve. The verified fix: set forcePathStyle: true on the S3 client config along with endpoint 'YOUR_HOST This switches to path-style (endpoint/bucket/key) and removes the bogus subdomain.
Evidence
Source: Stack Overflow #74378854 (accepted answer, 21 votes): using LocalStack S3 with AWS SDK v3 produced getaddrinfo ENOTFOUND bucket-name.YOURHOST. Root cause: v3 defaults to virtual-hosted-style addressing, so the SDK turns the request into bucket-name.YOURHOST, which does not resolve. The verified fix: set forcePathStyle: true on the S3 client config along with endpoint 'YOUR_HOST This switches to path-style (endpoint/bucket/key) and removes the bogus subdomain.
Verified resolution: When AWS SDK v3 talks to LocalStack S3 and you see getaddrinfo ENOTFOUND bucket-name.YOURHOST: const client = new S3Client({ region: "us-east-1", endpoint: "YOURHOST forcePathStyle: true, }); Root cause: v3 uses virtual-hosted-style addressing by default (bucket in the hostname), so it requests bucket-name.YOURHOST, which your machine cannot resolve. forcePathStyle: true switches to path-style (YOURHOST:4566/bucket/key). Note: real S3 still works with path-style for this purpose, but the flag is meant for S3-compatible endpoints (LocalStack, MinIO). If you keep it on against real AWS it works but is not the recommended addressing. Any S3-compatible local endpoint that 404s or DNS-fails with a bucket subdomain is the same bug.
Source URL: https://stackoverflow.com/questions/74378854
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_ZKU7dgzHW__WVE2hy0GCnQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">LocalStack S3 + AWS SDK v3: forcePathStyle true fixes bucket-name.a local/non-public address DNS errors <span>— Vectle</span></a>