---
title: "Deploy Kafka (w/Kafka UI)"
description: "One-click deploy: Kafka (KRaft) + Kafka UI"
category: "Queues"
url: https://railway.com/deploy/kafka-wkafka-ui
---

# Deploy Kafka (w/Kafka UI)

One-click deploy: Kafka (KRaft) + Kafka UI

**[Deploy Kafka (w/Kafka UI) on Railway](https://railway.com/template/kafka-wkafka-ui)**

- **Creator:** kinsyudev
- **Category:** Queues
- **Total deploys:** 39

## Template content

### Kafka UI https://avatars.githubusercontent.com/u/1528944

- **Source:** kinsyudev/kafka-railway
- **Health check:** /
- **Public domain:** Yes

### Kafka https://svn.apache.org/repos/asf/kafka/site/logos/originals/png/ICON%20-%20White%20on%20Transparent.png

- **Source:** kinsyudev/kafka-railway

## Documentation

# Deploy and Host Kafka + Kafka UI on Railway

Apache Kafka (single-broker, KRaft mode) plus Kafka UI, pre-configured for Railway. Kafka runs on Private Networking for secure, internal traffic; Kafka UI is exposed via HTTP for convenient topic and consumer inspection. Ideal for prototypes, tutorials, and staging environments that need event streaming without operational overhead.

## About Hosting Kafka + Kafka UI

This template deploys a single Kafka broker using Confluent's cp-kafka (KRaft, no ZooKeeper) and Kafka UI for observability. Your apps communicate with Kafka over Railway's Private Networking; only the UI is public. Use Kafka UI to browse topics, create partitions, inspect messages, and view consumer groups. The setup prioritizes simplicity over high availability, making it great for development, demos, and lightweight staging. Scale vertically by increasing service resources. For persistence across restarts, attach a Railway Volume to the Kafka service. Run client services in the same Railway project to reach the broker over its internal address and port.

## Common Use Cases

- Prototype and test event-driven microservices
- Demos, workshops, and learning Kafka basics
- Staging environments mirroring production topics

## Dependencies for Kafka + Kafka UI Hosting

- Railway project with Private Networking enabled
- Client services deployed in the same Railway project/network
- Optional Railway Volume for Kafka data persistence
- Recommended resources: ≥1 GB RAM for Kafka, ≥256 MB for Kafka UI

### Deployment Dependencies

- Confluent Kafka image: https://hub.docker.com/r/confluentinc/cp-kafka
- Kafka UI docs: https://docs.kafka-ui.provectus.io/
- Railway Private Networking: https://docs.railway.app/guides/private-networking
- Railway Volumes: https://docs.railway.app/guides/volumes

### Implementation Details

- Broker address: use the internal hostname/port shown in Railway service details.
- Kafka UI is preconfigured to connect over Private Networking.
- Single-broker KRaft is not HA; add brokers/partitions for resilience if needed.

## Why Deploy Kafka + Kafka UI on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Kafka + Kafka UI on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Services

- **Kafka** (single-broker, KRaft mode) via `confluentinc/cp-kafka:7.6.1`
- **Kafka UI** via `provectuslabs/kafka-ui:latest`

## Connecting to Kafka

### Environment Variables

Add these to your consumer/producer service on Railway:

```bash
KAFKA_BOOTSTRAP_SERVERS=${{ kafka.KAFKA_INTERNAL_URL }}
KAFKA_SECURITY_PROTOCOL=SASL_PLAINTEXT
KAFKA_SASL_MECHANISM=PLAIN
KAFKA_SASL_USERNAME=kafka
KAFKA_SASL_PASSWORD=${{ kafka.KAFKA_PASSWORD }}
```

For external access (requires TCP proxy enabled on Kafka service):

```bash
KAFKA_BOOTSTRAP_SERVERS=${{ kafka.KAFKA_URL }}
KAFKA_SECURITY_PROTOCOL=SASL_PLAINTEXT
KAFKA_SASL_MECHANISM=PLAIN
KAFKA_SASL_USERNAME=kafka
KAFKA_SASL_PASSWORD=${{ kafka.KAFKA_PASSWORD }}
```

### KafkaJS Example (Node.js/TypeScript)

```typescript
import { Kafka } from 'kafkajs';

const kafka = new Kafka({
  clientId: 'my-app',
  brokers: [process.env.KAFKA_BOOTSTRAP_SERVERS!],
  sasl: {
    mechanism: 'plain',
    username: process.env.KAFKA_SASL_USERNAME!,
    password: process.env.KAFKA_SASL_PASSWORD!,
  },
  ssl: false,
});

const producer = kafka.producer();
await producer.connect();
await producer.send({
  topic: 'test-topic',
  messages: [{ value: 'Hello Kafka!' }],
});
await producer.disconnect();

const consumer = kafka.consumer({ groupId: 'test-group' });
await consumer.connect();
await consumer.subscribe({ topic: 'test-topic', fromBeginning: true });
await consumer.run({
  eachMessage: async ({ topic, partition, message }) => {
    console.log({
      value: message.value?.toString(),
    });
  },
});
```


## Similar templates

- [smoothmq](https://railway.com/deploy/AJv-64) — A drop-in replacement for AWS SQS
- [Kafka UI](https://railway.com/deploy/kafka-ui) — Kafbat UI — Open-source web UI to monitor and manage Apache Kafka clusters
- [Hatchet Lite](https://railway.com/deploy/hatchet-lite) — Hatchet Lite with postgres

Open this page in a browser: https://railway.com/deploy/kafka-wkafka-ui
