> For the complete documentation index, see [llms.txt](https://docs.slingdata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.slingdata.io/sling-platform/platform/self-hosting.md).

# Self-Hosting

Deploy and manage Sling Platform in your own infrastructure

{% hint style="success" %}
Self-hosting is available with the [**Advanced plan**](https://slingdata.io/platform/#pricing). This feature allows you to deploy the entire Sling Platform within your private network for full control and security. **Start your 10-day trial at** [**https://dash.slingdata.io/self-platform**](https://dash.slingdata.io/self-platform)**, no credit card needed!** An organization is not necessary for the trial. When you subscribe, create your organization, make a new token, and set `SLING_PLATFORM_LICENSE` to it. The server moves your projects and users to your organization at the next start.
{% endhint %}

## Overview

Self-hosting Sling Platform enables organizations to:

* Maintain complete control over data and infrastructure
* Meet strict compliance and security requirements
* Deploy in air-gapped or private environments
* Customize deployment configurations

A deployment has two parts. The **platform** (`slingdata/sling-platform`) serves the web UI and API, and orchestrates work. One or more **agents** (`slingdata/sling`) connect to it and run the jobs. Data never flows through the platform — agents move it directly.

## Quick Start

### Run the platform

Run the command below, then open <http://localhost:7878>:

```bash
docker run -d \
  -p 7878:7878 \
  -p 4443:4443 \
  -e SLING_PLATFORM_LICENSE="your-license-key" \
  -e SLING_PLATFORM_ENCRYPTION_KEY="your-32-char-encryption-key" \
  -e SLING_PLATFORM_ADMIN_CREDENTIALS='{"email":"admin@example.com","password":"your-secure-password"}' \
  -v sling-platform-data:/home/sling \
  slingdata/sling-platform:latest
```

The container starts with an embedded PostgreSQL database, so nothing else is necessary to try it.

### Docker Compose

<details>

<summary>docker-compose.yaml</summary>

```yaml
services:
  sling-platform:
    image: slingdata/sling-platform
    ports:
      - "7878:7878"  # HTTP port for UI and API
      - "4443:4443"  # NATS WebSocket (agents + browser live logs)
    expose:
      - "7878"
      - "9876" # Embedded Postgres port accessible with user `sling` (not used with SLING_PLATFORM_POSTGRES_URL)
      - "4443"
    environment:
      SLING_PLATFORM_LICENSE: "your-license-key"
      SLING_PLATFORM_ENCRYPTION_KEY: "your-32-char-encryption-key"
      SLING_PLATFORM_ADMIN_CREDENTIALS: '{"email":"admin@example.com","password":"secure-password"}'
      SLING_PLATFORM_HOST: "http://external.ip:7878"  # External URL for web UI access
      SLING_PLATFORM_SMTP_CREDENTIALS: '{"host":"smtp.gmail.com","port":587,"user":"your-email","password":"your-password","from":"Sling <noreply@yourdomain.com>"}'
      # SLING_PLATFORM_SSO: '{"provider":"microsoft","tenant_id":"...","client_id":"...","client_secret":"..."}'
      # SLING_PLATFORM_MFA: "true"
    volumes:
      - sling-platform-data:/home/sling
    restart: unless-stopped
    
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7878/status/get"]
      interval: 5s
      timeout: 2s
      retries: 3

  # Add Agent(s) as needed
  # sling-agent:
  #   image: slingdata/sling:latest
  #   environment:
  #     SLING_PLATFORM_HOST: "http://sling-platform:7878"  # Internal container communication
  #     SLING_AGENT_KEY: "your-agent-key"
  #   command: agent run
  #   volumes:
  #     - sling-agent-data:/home/sling
  #   depends_on:
  #     - sling-platform
  #   restart: unless-stopped

volumes:
  sling-platform-data:
  sling-agent-data:
```

</details>

### Next steps

1. Open the web UI at your configured `SLING_PLATFORM_HOST`.
2. Log in with your admin credentials.
3. Create an agent key in the **Agents** section.
4. Deploy an agent with the `slingdata/sling` image. See [Agents](#agents).
5. Create connections and start building pipelines.

## Configuration

### Required variables

* **`SLING_PLATFORM_LICENSE`** - Your Sling Platform license key. This can be either a 36-character UUID for cloud-verified licenses or an offline license token for air-gapped environments. Obtain a trial key from <https://dash.slingdata.io/self-platform> (no credit card needed).
* **`SLING_PLATFORM_ENCRYPTION_KEY`** - A 32-character encryption key used to encrypt sensitive data like connection credentials. Generate a secure random string (`openssl rand -hex 16`).
* **`SLING_PLATFORM_ADMIN_CREDENTIALS`** - JSON payload containing the initial admin user credentials. need `email` and `password` keys.

{% hint style="success" %}
**Air-Gapped/Offline License**: By default, license tokens are validated through CloudFlare's global network for high reliability and fast response times. If you require an air-gapped or high-security environment, we offer offline license tokens that don't require internet connectivity for validation. These require yearly renewal by default, but perpetual licenses are also available. Please contact <support@slingdata.io> to request a quote.
{% endhint %}

### Optional variables

* **`SLING_PLATFORM_HOST`** - The external URL where your platform will be accessible. This is used for agent connections and web UI access. The default is `http://localhost:7878`
* **`SLING_PLATFORM_POSTGRES_URL`** - Optional connection URL for your own PostgreSQL server. When set, the platform does not start the embedded database. See [External PostgreSQL](#external-postgresql).
* **`SLING_PLATFORM_HOST_WS`** - Optional override for the NATS WebSocket URL used by **both** agents and the browser (live log streaming). Default derives from `SLING_PLATFORM_HOST`: same hostname, port `4443`, scheme `http`→`ws` / `https`→`wss`. Example: `wss://sling.example.com:4443` behind a TLS proxy, or `ws://<node>:4443` for plain HTTP. One env var configures agents and browsers.
* **`SLING_PLATFORM_SMTP_CREDENTIALS`** - SMTP configuration for email notifications. If your SMTP service requires SSL, specify the optional `security` key with the value `SSL`. If not provided, email notifications will be disabled. For example: `{"host":"smtp.gmail.com","port":587,"user":"your-email@gmail.com","password":"your-app-password","from":"Sling Platform <noreply@yourdomain.com>", "security": "SSL"}`
* **`SLING_PLATFORM_SSO`** - Optional JSON (or bare provider name) that enables OpenID Connect login. See [SSO & MFA](/sling-platform/platform/self-hosting/sso-mfa.md#single-sign-on-microsoft-entra-id--oidc). Requires the Advanced plan.
* **`SLING_PLATFORM_MFA`** - Optional `true` or JSON that enables TOTP multi-factor authentication for email/password logins. See [SSO & MFA](/sling-platform/platform/self-hosting/sso-mfa.md#multi-factor-authentication). Requires the Advanced plan.
* **`SLING_PLATFORM_ASSISTANT`** - Optional JSON payload that configures the [AI Assistant](/sling-platform/platform/ai-assistant.md) model endpoint. Prefer **Settings → AI & MCP → Configure** on a running server; this variable is a fallback when nothing is saved in the UI. Requires a `model` key. For example: `{"api_format":"anthropic","model":"claude-sonnet-5","api_key_env":"ANTHROPIC_API_KEY"}`. See [AI Assistant](/sling-platform/platform/ai-assistant.md#configuration-reference) for all fields.
* **SLING\_LOGGING** - The default logger uses ANSI colors. You can change this if you'd like, accepts values: `NO_COLOR` or `JSON`.

### Ports

* **7878** - Main HTTP port for web UI and API access
* **4443** - NATS WebSocket. Agents use this, and the **browser** uses it for live execution log streaming. Port 4443 must be reachable from the user's browser (not only from in-cluster agents). If it is not, the UI falls back to polling every 5 seconds and logs appear delayed.

### Storage

* `/home/sling` - Platform data directory.

{% hint style="info" %}
**Embedded Database**: By default, the sling-platform container includes an embedded PostgreSQL database. Database files are stored under `/home/sling/platform/postgres` within the container. This database is accessible on port 9876 with username `sling` (read-only) and password `pgpass.$PREFIX`, where `$PREFIX` is the first 6 characters of `SLING_PLATFORM_ENCRYPTION_KEY`. The database name is `sling_platform`.

Here is the env var to have Sling read from the Platform database (replace `$PREFIX` and `$SLING_PLATFORM_HOST`): `SLING_PLATFORM_DB='postgresql://sling:pgpass.$PREFIX@$SLING_PLATFORM_HOST:9876/sling_platform?sslmode=disable'`

The read-only `sling` user and port 9876 only exist with the embedded database. See [External PostgreSQL](#external-postgresql) to use your own server instead.
{% endhint %}

## Agents

Agents run your jobs. Each one connects to the platform with a key you create in the **Agents** section of the UI.

### Connect an agent

Use the `slingdata/sling` image with these environment variables:

```bash
docker run -d \
  -e SLING_PLATFORM_HOST="http://your-platform-host:7878" \
  -e SLING_AGENT_KEY="your-agent-key-from-platform-ui" \
  -v sling-agent-data:/home/sling \
  slingdata/sling agent run
```

* **`SLING_AGENT_KEY`** - Agent authentication key obtained from the platform UI under Agents section
* **`SLING_PLATFORM_HOST`** - Same URL as your platform instance
* **`SLING_PLATFORM_HOST_WS`** - Optional, the WebSocket URL for the NATS connection, e.g. `ws://your-platform-host:4443`. Default derives from `SLING_PLATFORM_HOST` (same hostname, port `4443`, `ws`/`wss` per scheme). Set the same value on the platform so the browser uses it too.

To run several agent replicas on one key, with load balancing and failover, see [High-Availability Agents](/sling-platform/platform/self-hosting/shared-mode.md).

### Custom agent image

If you need to build your own custom Sling agent Docker image (for example, to include additional dependencies or configurations), you can use the official Dockerfiles as a starting point:

* **AMD64 Architecture**: [Dockerfile](https://github.com/slingdata-io/sling-cli/blob/main/cmd/sling/Dockerfile)
* **ARM64 Architecture**: [Dockerfile.arm64](https://github.com/slingdata-io/sling-cli/blob/main/cmd/sling/Dockerfile.arm64)

See [here](/sling-platform/platform/agents.md#custom-agent-docker-image) for an example.

## Production Setup

### External PostgreSQL

Set `SLING_PLATFORM_POSTGRES_URL` to use your own PostgreSQL server instead of the embedded one. The platform then stores all state in that database. The `/home/sling` volume only holds caches and working files.

```bash
docker run -d \
  -p 7878:7878 \
  -p 4443:4443 \
  -e SLING_PLATFORM_LICENSE="your-license-key" \
  -e SLING_PLATFORM_ENCRYPTION_KEY="your-32-char-encryption-key" \
  -e SLING_PLATFORM_ADMIN_CREDENTIALS='{"email":"admin@example.com","password":"your-secure-password"}' \
  -e SLING_PLATFORM_POSTGRES_URL="postgresql://sling_platform:password@db.internal:5432/sling_platform?sslmode=require" \
  -v sling-platform-data:/home/sling \
  slingdata/sling-platform:latest
```

**Requirements:**

* PostgreSQL 14 or later. The embedded database is PostgreSQL 16.
* A dedicated database. The platform creates and alters tables in the `public` schema on startup.
* A user that owns the database, or has `CREATE` on the `public` schema and owns all platform tables. No superuser rights and no extensions are necessary.
* Network access from the platform container to the database. Set `sslmode` in the URL as your server requires.

**Notes:**

* The platform does not create the read-only `sling` user on an external database. Create your own read-only role if you need one.
* The embedded database limits connections to 50. Size your server's `max_connections` for the platform plus your other clients.
* Keep the same `SLING_PLATFORM_ENCRYPTION_KEY`. Connection credentials in the database are encrypted with it.

### Security

* Use strong, unique values for `SLING_PLATFORM_ENCRYPTION_KEY` (32 characters)
* Store sensitive environment variables securely
* Use HTTPS in production environments

{% hint style="warning" %}
Self-hosting requires careful consideration of security, backup, and maintenance procedures. Ensure your team has the necessary expertise to manage the deployment.
{% endhint %}

### More deployment options

| Page                                                                             | What it covers                                                               |
| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [Kubernetes](/sling-platform/platform/self-hosting/kubernetes.md)                | Full manifest for the platform and an agent                                  |
| [High-Availability Agents](/sling-platform/platform/self-hosting/shared-mode.md) | Shared mode, failover, and platform-managed replicas on Docker or Kubernetes |
| [SSO & MFA](/sling-platform/platform/self-hosting/sso-mfa.md)                    | OpenID Connect login and TOTP multi-factor authentication                    |

## Troubleshooting

### Common issues

1. **Platform won't start**
   * Check container logs: `docker logs sling-platform`
   * Verify environment variables are set correctly
   * Ensure data volume has sufficient permissions
2. **Agents not connecting**
   * Verify network connectivity between agent and platform
   * Check agent key is valid and properly set
   * Ensure platform URL is accessible from agent
   * Review agent logs for error messages
3. **Performance issues**
   * Increase resource limits (CPU/memory)
   * Scale agents horizontally for more concurrent jobs
   * Monitor disk space for data volume

### Getting help

If you are facing issues setting up, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.slingdata.io/sling-platform/platform/self-hosting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
