LocalStack diagnostics: logging with DEBUG=1 and localstack logs, the health endpoint, Docker resource monitoring, and how to fix port conflicts and lost persistence.

In episode 18 we deployed LocalStack to CI and the pipeline runs automatically. But when something gets stuck — Lambda not invoked, port collision, lost state — debugging skills are what decide the outcome. This episode closes Phase 5 with Performance & Troubleshooting: how to read logs, check health, monitor resources, and solve the most common problems. This isn't theory — it's a checklist you'll use almost every day.
By default, LocalStack's logs are fairly quiet. For investigation, enable debug mode at startup:
DEBUG=1 localstack startOr via environment variables on the container:
docker run -d --name ls-debug -e DEBUG=1 -p 4566:4566 localstack/localstack:stableView the logs with:
localstack logs
docker logs -f ls-debugWith DEBUG=1, every request is recorded in full, including status and its trace. Turn it off when not needed — debug mode produces a huge amount of logs and slows the instance down slightly.
The fastest way to confirm a service is alive is the health endpoint:
curl -s http://localhost:4566/_localstack/healthThe response is JSON containing the status of each service:
{
"services": {
"s3": "running",
"dynamodb": "running",
"lambda": "available",
"iam": "available"
}
}running means the service is active; available means it's ready to activate on first call; while error or stopped indicates a problem. This endpoint is very useful as a readiness check in CI or an orchestrator — we also used it in episode 18.
LocalStack runs on top of a container, so the primary monitoring tool is Docker:
docker stats --no-stream localstack
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.CPUPerc}}"If memory spikes, check how many services are active and narrow them down via SERVICES:
SERVICES=s3,dynamodb,lambda localstack startFewer active services means fewer processes and less memory used. A bloated persistence volume can also be measured:
docker exec localstack du -sh /var/lib/localstackThe classic error: port 4566 is already in use. The cause is an old instance still running, or another process attached to the port. Detect it with:
lsof -i :4566
docker psThen clean up the old instance:
localstack stop
docker rm -f localstackAn alternative: run on a different port — exactly like the per-developer isolation strategy from episode 15.
A Lambda that doesn't respond is usually caused by one of these:
| Symptom | Common cause | Solution |
|---|---|---|
| Invoke hangs or times out | Runtime image not available | Check logs, make sure Docker can pull the runtime |
| Event source mapping silent | Mapping targets the wrong thing | Verify the source arn and mapping status |
| Function error at runtime | Code depends on a down service | Make sure all dependency services are up |
The first step is always the same: enable DEBUG=1, then run awslocal lambda invoke. Errors inside the function code will appear in the logs with a full traceback or stack trace. Also make sure LAMBDA_EXECUTOR points to a mode supported by your environment (e.g. Docker).
Persistence not working is usually caused by one of these:
PERSISTENCE=1 wasn't set when the instance was first created.docker run without the -v argument.Check the data location and the mounted volume:
docker exec localstack ls /var/lib/localstack
docker inspect localstack --format '{{.Mounts}}'If the folder is empty, persistence was never active. The fix: restart the instance with PERSISTENCE=1 and a named volume like the example in episode 15.
A CLI and image on different versions often produce weird behavior. Make sure both are in sync:
localstack --version
docker pull localstack/localstack:stable
localstack statusThe stable tag always points to the latest stable release. After upgrading, check the changelog — some releases change default behavior that can break assumptions in old code.
Many "problems" are actually deliberate emulation limits:
The best way to know what's supported: read the official per-service documentation or the release changelog. If a feature isn't available, the alternative is testing directly on a real AWS account.
LocalStack troubleshooting checklist:
DEBUG=1 and read localstack logs for unclear symptoms./_localstack/health as a readiness check.docker stats and limit services with SERVICES.lsof -i :4566, then clean up old instances.PERSISTENCE and the volume mount.With Phase 5 complete, we have a solid foundation: from networking, security, and advanced services to CI/CD and debugging. In the next episode 20 we discuss the latest stable 2026.x features: calendar versioning, the single Community and Pro image, and the 2026.07.0 release highlights. See you there!