-
Notifications
You must be signed in to change notification settings - Fork 2
Description
🐛 Bug Description
What happened?
When the connection string is produced, it includes the LocalStack URL as visible from the host machine (e.g., localhost:4567). However, inside the container, only port 4566 is accessible. If the connection string uses a different port (like 4567), components inside the container such as awslocal or health checks cannot connect to LocalStack.
The environment variable LOCALSTACK_HOST is injected/reused in the container and in health checks for connectivity. In my setup, I pin LocalStack's host port to 4567 by setting the container's Port configuration. This results in LOCALSTACK_HOST=localhost:4567, but it should be localhost:4566 for internal container connections.
See the relevant code for context:
Line 42 in b7fa6c8
| resourceBuilder.WithEnvironment("LOCALSTACK_HOST", $"{localStackUrl.Host}:{localStackUrl.Port.ToString(CultureInfo.InvariantCulture)}"); |
What did you expect to happen?
LOCALSTACK_HOST inside the container should always reference localhost:4566, regardless of the externally pinned host port. This ensures connectivity for awslocal and health checks.
🔄 Steps to Reproduce
- Configure LocalStack container with
Port=4567(or any port != 4566). - Check injected
LOCALSTACK_HOSTenvironment variable inside container. - Attempt to use awslocal or health checks within the container.
- Observe failed connectivity.
Minimal code example:
var builder = DistributedApplication.CreateBuilder(args);
var localstack = builder.AddLocalStack(configureContainer: options => {
options.Port = 4567;
});
// Components relying on LOCALSTACK_HOST inside container fail
builder.Build().Run();📋 Environment Information
.NET Aspire Information:
- Aspire Version: 13
LocalStack Information:
- LocalStack Image: 4.13.1
.NET Information:
- .NET Version: 8
Aspire Configuration (Optional):
{
"LocalStack": {
"UseLocalStack": true,
}
}Error Messages/Stack Traces:
Connection failed: awslocal could not reach localhost:4567 from inside container
Health check failed inside container