---
title: "Deploy Flask WebSocket Chat"
description: "Single file, realtime multi-user websocket chat using flask-socketio"
category: "Starters"
url: https://railway.com/deploy/flask-websocket-chat
---

# Deploy Flask WebSocket Chat

Single file, realtime multi-user websocket chat using flask-socketio

**[Deploy Flask WebSocket Chat on Railway](https://railway.com/template/flask-websocket-chat)**

- **Creator:** Clement Ochieng's Projects
- **Category:** Starters
- **Total deploys:** 3

## Template content

### flask-websocket-chat

- **Source:** Oclemy/flask-websocket-chat

## Documentation

# Deploy and Host Flask WebSocket Chat on Railway

A real-time chat application built with Flask and Flask-SocketIO. It uses WebSockets (with polling fallback) to broadcast messages instantly between all connected clients. Features automatic reconnection, online user counting, and a clean dark-themed UI—all in a single Python file.

## About Hosting Flask WebSocket Chat

Hosting Flask WebSocket Chat requires a platform that supports persistent WebSocket connections alongside standard HTTP traffic. The app runs on Gunicorn with an Eventlet async worker, which handles concurrent WebSocket connections efficiently in a single process. Railway provisions the PORT environment variable automatically, and the app binds to it on startup. No database or external storage is needed—messages are relayed in real time and chat state lives in memory. The deployment consists of just two files: `main.py` and `requirements.txt`, making it straightforward to deploy and maintain.

## Common Use Cases

- Learning how WebSockets work in Python with a hands-on, deployable example
- Adding real-time chat or notifications to an existing Flask application
- Prototyping collaborative features like live cursors, shared editing, or multiplayer interactions

## Dependencies for Flask WebSocket Chat Hosting

- Python 3.10+
- Gunicorn (WSGI server)

### Deployment Dependencies

- [Flask](https://flask.palletsprojects.com/) — lightweight web framework
- [Flask-SocketIO](https://flask-socketio.readthedocs.io/) — WebSocket support for Flask
- [Eventlet](https://eventlet.readthedocs.io/) — async networking library for concurrent WebSocket handling
- [Socket.IO Client](https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.5/socket.io.min.js) — browser-side WebSocket client (loaded via CDN)

### Implementation Details

The app is served with Gunicorn using the Eventlet worker class to support async WebSocket connections:
```bash
gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:$PORT main:app
```

## Why Deploy Flask WebSocket Chat 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 Flask WebSocket Chat 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.

## Similar templates

- [open-excalidraw](https://railway.com/deploy/open-excalidraw) — Self-hostable collaborative drawing built on Excalidraw
- [caring-vibrancy](https://railway.com/deploy/caring-vibrancy) — Deploy and Host caring-vibrancy with Railway
- [Appsmith](https://railway.com/deploy/appsmith-1) — Low-code platform for internal tools, dashboards, and admin panels.

Open this page in a browser: https://railway.com/deploy/flask-websocket-chat
