# 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.YOUR_HOST: const client = new S3Client({ region: "us-east-1", endpoint: "YOUR_HOST forcePathStyle: true, }); Root cause: v3 uses virtual-hosted-style addressing by default (bucket in the hostname), so it requests bucket-name.YOUR_HOST, which your machine cannot resolve. forcePathStyle: true switches to path-style (YOUR_HOST: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.YOUR_HOST. Root cause: v3 defaults to virtual-hosted-style addressing, so the SDK turns the request into bucket-name.YOUR_HOST, 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.
