pg-boss: PostgreSQL Job Queue for Node.js

repository·master·Indexed Apr 15, 2026

https://github.com/timgit/pg-boss

pg-boss is a reliable job queue for Node.js built on PostgreSQL. It leverages SKIP LOCKED for exactly-once delivery, supports cron scheduling, priority queues, and dead letter queues. Features include a web-based Dashboard for monitoring, a CLI for management, and an HTTP Proxy. The library handles job states (created, active, completed, retry, failed, cancelled) and offers event listeners for errors, warnings, and worker activity. It supports custom database connections, schema partitioning, and advanced configuration options for maintenance and migrations.

Tokens
38.9K
Snippets
150
Records
218
Agent score
87%

What's inside pg-boss

  1. Overview: What is pg-boss

    master

    pg-boss is a job queue built in Node.js on top of PostgreSQL, providing background processing and reliable asynchronous execution. It leverages PostgreSQL's SKIP LOCKED feature for exactly-once delivery, ensuring safe record locking and guaranteed atomic commits. It is designed for teams familiar with relational database semantics (SQL, querying, backups) and aims to reduce architectural complexity by using PostgreSQL as the sole queue backend.

    Sources: docs/README.md

  2. Introduction

    master

    pg-boss is a job queue powered by PostgreSQL, operated by one or more Node.js instances. It leverages PostgreSQL's SKIP LOCKED feature to resolve record locking challenges inherent with relational databases, providing exactly-once delivery and guaranteed atomic commits for asynchronous job processing.

    This library is ideal for teams familiar with relational database semantics (SQL, querying, backups) who want to minimize the number of systems required to monitor and support their architecture.

  3. Managing Job Lifecycle

    master

    Jobs that are not actively deleted will remain in completed, cancelled, or failed state until they are automatically removed by the system.

    Sources: docs/introduction.md

  4. Dashboard Features Overview

    master

    The dashboard provides the following features for monitoring and managing pg-boss:

    • Overview Dashboard: View aggregate statistics, problem queues, and recent warnings.
    • Queue Management: Browse all queues with real-time stats (queued, active, deferred, total).
    • Job Browser: View and manage individual jobs with smart filtering (defaults to pending jobs).
    • Job Actions: Create, cancel, retry, resume, or delete jobs directly from the UI.
    • Warning History: Track slow queries, queue backlogs, and clock skew issues.
    • Multi-Database Support: Monitor multiple pg-boss instances from a single dashboard.

    Sources: docs/dashboard.md

  5. Dashboard Features Overview

    master

    The pg-boss Dashboard provides the following capabilities:

    • Overview: Aggregate statistics, problem queues, and recent warnings at a glance
    • Queue Management: View all queues with cached statistics and create new queues
    • Job List: View jobs with state and queue filtering
    • Job Details: View full job payloads, output data, and metadata
    • Job Actions: Create, cancel, retry, resume, or delete jobs directly from the UI
    • Warning History: Browse through previously emitted warning events (when persistWarnings is enabled)
    • Multi-Schema Support: Monitor multiple pg-boss instances from a single dashboard
    • Mobile Responsive: Full functionality on mobile devices with collapsible sidebar
    • Shareable URLs: Database selection and filters are preserved in URLs for easy sharing

    The dashboard is built with React Router 7, Hono, Tailwind CSS v4, and Base UI components.

    Sources: packages/dashboard/README.md

  6. Deploy to Production: Docker

    master

    Deploy the dashboard using Docker:

    Dockerfile:

    FROM node:24
    WORKDIR /app
    RUN npm install -g @pg-boss/dashboard
    ENV PORT=3000
    EXPOSE 3000
    CMD ["pg-boss-dashboard"]

    Build and run:

    docker build -t pgboss-dashboard .
    docker run -d \
      -e DATABASE_URL="postgres://user:pass@host:5432/db" \
      -p 3000:3000 \
      pgboss-dashboard

    This approach provides containerized deployment with automatic dependency management.

    docker run -d -e DATABASE_URL="postgres://user:pass@host:5432/db" -p 3000:3000 pgboss-dashboard

    Sources: packages/dashboard/README.md

  7. Development: Run Dashboard from Source

    master

    To work on the dashboard from source:

    # Clone the pg-boss repository
    git clone https://github.com/timgit/pg-boss.git
    cd pg-boss/packages/dashboard
    
    # Install dependencies
    npm install
    
    # Initialize local database with pg-boss schema and test queues
    npm run dev:init-db
    
    # Start development server with hot reloading
    npm run dev
    
    # (Optional) Start a worker to process jobs
    npm run dev:worker
    
    # Build for production
    npm run build
    
    # Run production build
    npm start

    Notes:

    • dev:init-db connects to postgres://postgres:postgres@127.0.0.1:5432/pgboss by default
    • dev:worker runs in a separate terminal and stays running until stopped with Ctrl+C
    • The worker processes jobs from the same pg-boss instance as the dashboard
    npm run dev:init-db && npm run dev

    Sources: packages/dashboard/README.md

  8. Running in Other Runtimes

    master

    For runtime-neutral usage (e.g., Deno, Bun, or custom environments), use createProxyService and manually wire shutdown listeners (see "Lifecycle Wiring by Runtime").

    import { createProxyServerNode } from '@pg-boss/proxy/node'
    
    const proxy = await createProxyServerNode()
    await proxy.start()

    Sources: packages/proxy/README.md