Connecting Services
Services within a Stackpad project communicate over a private Docker network using simple DNS names. No IP addresses, no external URLs, no configuration — just use the service name as the hostname.
How it works
When you create a project, Stackpad creates an isolated Docker network for that project. Every service in the project is attached to this network and gets a DNS alias matching its name.
For example, if your project has:
- A web service called
web - A PostgreSQL service called
postgres - A Redis service called
redis
Then from your web service, you can connect to:
| Service | Hostname | Port |
|---|---|---|
| PostgreSQL | postgres | 5432 |
| Redis | redis | 6379 |
| Another web service | api | 3000 |
// Connect to PostgreSQLconst db = new Pool({ host: 'postgres', port: 5432 });
// Connect to Redisconst redis = new Redis({ host: 'redis', port: 6379 });
// Call another serviceconst response = await fetch('http://api:3000/health');Automatic credential injection
For database and cache services, Stackpad goes a step further — it automatically generates credentials and injects connection strings into your web services:
| Service type | Environment variable |
|---|---|
| PostgreSQL | DATABASE_URL=postgresql://user:pass@postgres:5432/db |
| MariaDB | MYSQL_URL=mysql://user:pass@mariadb:3306/db |
| Redis | REDIS_URL=redis://redis:6379 |
| Valkey | REDIS_URL=redis://valkey:6379 |
Your application just reads process.env.DATABASE_URL and it works.
Network isolation
Each project has its own isolated network. Services from different projects cannot communicate with each other. This ensures:
- Security — no cross-project data leaks
- DNS isolation —
postgresin project A resolves to a different container thanpostgresin project B - Performance — no noisy-neighbor effects on network traffic
External access
By default, only web services are exposed externally via HTTPS. Databases and caches are only accessible from within the project’s private network.
This is a security best practice — your database should never be directly accessible from the internet.
What’s next?
- PostgreSQL — add a database to your project
- Redis & Valkey — add caching to your project
- Networking concepts — deep dive into the networking architecture