This guide covers common issues you might encounter while using pgpm and how to fix them quickly.
Table of Contents
Postgres Issues
Docker not running
Symptom:
Solution:
Start Docker Desktop and ensure it's running before executing pgpm docker start.
Postgres not accepting connections
Symptom:
Solution:
Testing Issues
Tests fail to connect to database
Symptom: Tests time out or fail with connection errors
Solution: Ensure Postgres is running and users are bootstrapped:
Current transaction is aborted in tests
Symptom:
When testing operations that should fail (RLS violations, permission errors, constraint violations), subsequent queries on the same connection fail with:
The Problem:
In Postgres, any error inside a transaction marks the entire transaction as aborted. After that, every further query on that connection fails until you explicitly end the transaction.
This is particularly painful in tests where you intentionally assert failures (e.g., expect(...).rejects.toThrow(...)) and then want to continue using the same db connection.
Solution: Use Savepoints
Wrap each "expected-to-fail" operation in a savepoint, and roll back to that savepoint after the failure. This clears the error state while keeping the surrounding transaction open.
Pattern:
Example: Anonymous users cannot modify data
By using savepoints + rollback, you can:
- Assert failures safely
- Keep using the same
dbtransaction - Avoid
current transaction is abortederrors entirely
For more details, see Advanced: Handling Exceptions and Aborted Transactions.
Environment Variable Issues
Environment variables not set
Symptom: Commands fail with "PGHOST not set" or similar
Solution: Load pgpm environment:
To make permanent, add to your shell config:
