Electric: PostgreSQL Sync Engine

Self-host Electric on Pigsty v4.2 to sync PostgreSQL data to frontend apps with partial replication and real-time delivery.

Electric is a PostgreSQL sync engine focused on efficiently delivering database changes to frontend and edge applications.

Pigsty v4.2 provides the app/electric template (conf/app/electric.yml) to bootstrap database, container, and ingress settings in one flow.

Quick Start

curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty
./bootstrap
./configure -c app/electric
vi pigsty.yml                 # update domain, passwords, secrets
./deploy.yml
./docker.yml
./app.yml

Default endpoints:

  • http://<IP>:8002
  • http://elec.pigsty (default domain in the template)

Metrics port defaults to 8003 (ELECTRIC_PROMETHEUS_PORT).

Key Settings

conf/app/electric.yml writes apps.electric.conf into /opt/electric/.env. Common parameters:

  • DATABASE_URL: PostgreSQL connection string used by Electric (replication privileges required)
  • ELECTRIC_PORT: Electric HTTP port (default 8002)
  • ELECTRIC_PROMETHEUS_PORT: metrics port (default 8003)
  • ELECTRIC_INSECURE: can be true in dev; disable in prod and use proper secrets

Operations

cd /opt/electric
make up
make logs
make down

References


Last Modified 2026-02-28: v4.2 (5b1f22b)