
Deploy LocalStack — AWS Emulator
An AWS cloud emulator for development, testing, and CI workflows.
localstack
Just deployed
/var/lib/localstack
Deploy and Host LocalStack on Railway
LocalStack is a cloud service emulator that provides AWS-compatible APIs for development, testing, automation, and CI/CD workflows.
It allows applications to interact with services such as S3, SQS, SNS, DynamoDB, Secrets Manager, SSM, IAM, STS, and many other AWS APIs without connecting directly to production AWS infrastructure.
About Hosting LocalStack
This template deploys LocalStack on Railway using the official localstack/localstack Docker image.
LocalStack exposes AWS-compatible APIs through a unified gateway on port 4566. AWS CLI, AWS SDKs, applications, and automation tools can connect to the Railway public domain and use it as a custom AWS endpoint.
A Railway persistent volume is mounted at:
/var/lib/localstack
With persistence enabled, supported LocalStack resources and state can survive container restarts and redeployments.
Important: A valid
LOCALSTACK_AUTH_TOKENis required to start current LocalStack releases. You can obtain your token from https://app.localstack.cloud.
Because Railway does not expose the host Docker daemon or /var/run/docker.sock, LocalStack features that require additional Docker containers may be unavailable or limited.
Common Use Cases
- Develop applications against AWS-compatible APIs without using production AWS resources
- Test S3-compatible object storage integrations
- Test SQS and SNS messaging workflows
- Develop and test DynamoDB integrations
- Test Secrets Manager, SSM, IAM, STS, and other supported AWS APIs
- Run integration tests in CI/CD pipelines
- Test AWS CLI and AWS SDK configurations
- Create isolated AWS-like development and QA environments
- Provide a remotely accessible AWS emulator for development teams
Dependencies for LocalStack Hosting
- Official
localstack/localstackDocker image - Valid LocalStack Auth Token
- Railway HTTP networking on port
4566 - Railway persistent volume mounted at
/var/lib/localstack
No external PostgreSQL, Redis, MinIO, or other database service is required for the default deployment.
Configuration
This template uses a minimal configuration:
PORT="4566"
DEBUG="0"
PERSISTENCE="1"
LOCALSTACK_AUTH_TOKEN=""
Environment Variables
PORT=4566— LocalStack gateway port used by Railway networkingDEBUG=0— set to1to enable verbose LocalStack debuggingPERSISTENCE=1— persists supported LocalStack state across container restartsLOCALSTACK_AUTH_TOKEN— required LocalStack authentication token from https://app.localstack.cloud
Before Deploying
You must have a valid LocalStack Auth Token.
- Open https://app.localstack.cloud
- Sign in or create a LocalStack account
- Copy your LocalStack Auth Token
- Enter the token into the
LOCALSTACK_AUTH_TOKENvariable when deploying the Railway template
Do not replace the token with a randomly generated Railway secret. It must be a valid token issued by LocalStack.
If the token is missing or invalid, LocalStack may stop during startup and Railway will return a 502 Bad Gateway because no application is listening on port 4566.
Railway Configuration
The template uses:
Docker Image
localstack/localstack
Target Port
4566
Volume
/var/lib/localstack
No custom start command is required.
After Deployment
Once the deployment is running, Railway will provide a public domain similar to:
https://your-localstack.up.railway.app
This domain becomes your LocalStack AWS endpoint.
You can verify that LocalStack is running by opening:
https://your-localstack.up.railway.app/_localstack/health
A successful response indicates that the LocalStack gateway is reachable.
Connecting with AWS CLI
AWS CLI can connect to LocalStack by specifying the Railway public domain with --endpoint-url.
Example:
aws \
--endpoint-url=https://your-localstack.up.railway.app \
s3 ls
For LocalStack development environments, dummy AWS credentials can normally be used by AWS clients:
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
export AWS_DEFAULT_REGION=us-east-1
You can then create an S3 bucket:
aws \
--endpoint-url=https://your-localstack.up.railway.app \
s3 mb s3://my-test-bucket
And list your buckets:
aws \
--endpoint-url=https://your-localstack.up.railway.app \
s3 ls
Connecting with AWS SDK
Use the Railway public domain as the AWS SDK endpoint.
Example using AWS SDK for JavaScript:
import { S3Client } from "@aws-sdk/client-s3";
const s3 = new S3Client({
region: "us-east-1",
endpoint: "https://your-localstack.up.railway.app",
credentials: {
accessKeyId: "test",
secretAccessKey: "test"
},
forcePathStyle: true
});
S3 Path-Style Access
When using S3 through a Railway-generated public domain, path-style addressing is recommended:
forcePathStyle: true
This avoids relying on wildcard bucket subdomains such as:
bucket-name.your-localstack.up.railway.app
which may not be available through the Railway-generated domain.
Railway Deployment Architecture
Application / AWS CLI / AWS SDK
│
│ HTTPS
▼
Railway Public Domain
│
▼
LocalStack Gateway
:4566
│
▼
/var/lib/localstack
Railway Volume
LocalStack vs AWS
| Feature | LocalStack on Railway | AWS |
|---|---|---|
| AWS-compatible APIs | ✅ | ✅ |
| Development and testing | ✅ | ✅ |
| AWS production infrastructure | ❌ | ✅ |
| Requires AWS production resources | ❌ | ✅ |
| LocalStack account/token | ✅ | ❌ |
| Persistent state |