1. EasyHost
  2. Guides
  3. Koa
  4. Sequelize

Use Sequelize with Koa and Postgres

Connect a Koa app to a free EasyHost Postgres database using Sequelize, from install to deployment.

Last updated November 9, 2026

Create the database

npx ezhst db create main
npx ezhst db info --json
npx ezhst env set DATABASE_URL="postgresql://..."

The connection string uses a public host with TLS, so it works from your laptop too. Put it in your local .env for development.

Install Sequelize

npm i sequelize pg pg-hstore

Create the client

src/db.ts
import pg from "pg";
import { Sequelize } from "sequelize";

export const db = new Sequelize(process.env.DATABASE_URL!, {
  dialect: "postgres",
  dialectModule: pg,
  pool: { max: 5 },
});

dialectModule: pg avoids dynamic require errors in bundled frameworks. A pool of 5 leaves room within the limit of 20 connections.

Koa does not bundle your code, so drivers load normally from node_modules.

Query it from a route

src/index.ts
import { db } from "./db";
router.get("/api/users", async (ctx) => {
  const [rows] = await db.query("select id, email from users limit 20");
  ctx.body = rows;
});

Run migrations

Run migrations from your machine, with DATABASE_URL set to the EasyHost connection string.

npx sequelize-cli db:migrate

Commit the migration files so every environment applies the same changes.

Deploy

npx ezhst deploy

Each database allows 20 concurrent connections, and Koa shares them across requests. See the Koa hub for every Koa guide, or free Koa hosting for what is included. See also the Postgres product page.

Frequently asked questions

Is Postgres free for my Koa app?

Yes. Each EasyHost project can have one Postgres 16 database with no expiry date.

Can I use Sequelize locally against the same database?

Yes. The connection string works from outside EasyHost. A separate development database is safer once you have real data.

Start for free

Install the skill, choose Global or Local, then tell your agent to deploy. No credit card, no config files.

npx ezhst skill install