Configuration

PgArachne loads configuration from environment variables or a file.

Note: schema.sql attempts to create the pgarachne_admin role and grant it to pgarachne. If you run the script without superuser privileges, role creation is skipped. Create the role and grant it manually if needed.
The proxy user (DB_USER) must be a member of pgarachne and pgarachne_admin to verify and mint API tokens.
Security Note: PgArachne does not handle database passwords in the configuration file. Rely on the standard PostgreSQL .pgpass file mechanism (or PGPASSWORD system variable) for authentication.
Tip: If you run PgArachne behind a reverse proxy, set TRUSTED_PROXIES so client IPs are resolved correctly and rate limiting cannot be spoofed.
Search Order: If no configuration file is specified via CLI, it searches in:
  1. Current directory: ./pgarachne.env (All OS)
  2. User config:
    • Linux / macOS: ~/.config/pgarachne/pgarachne.env
    • Windows: %USERPROFILE%\.config\pgarachne\pgarachne.env
  3. System config: /etc/pgarachne/pgarachne.env (Linux / macOS only)

Minimal Configuration Example

This is all you need to get started:

DB_HOST=localhost
DB_PORT=5432
DB_USER=pgarachne
JWT_SECRET=change_me_to_something_secure

Required variables: DB_HOST, DB_PORT, DB_USER, JWT_SECRET.

Configuration Reference

VariableRequiredDescription
Database Connection
DB_HOSTYesPostgreSQL server address (e.g., localhost).
DB_PORTYesDatabase port.
DB_USERYesThe database user PgArachne connects with.
DB_SSLMODENoPostgreSQL SSL mode. Default: disable.
DB_SSLROOTCERTNoPath to CA root certificate (PEM).
DB_SSLCERTNoPath to client certificate (PEM).
DB_SSLKEYNoPath to client private key (PEM).
HTTP Server
HTTP_PORTNoPort to listen on. Default: 8080.
ALLOWED_ORIGINSNoCORS settings. Comma separated list of allowed domains (e.g. https://myapp.com). Default: *.
STATIC_FILES_PATHNoAbsolute path to serve static files (Explorer/Frontend).
Security (JWT)
JWT_SECRETYesA long, random string used to sign session tokens.
JWT_EXPIRY_HOURSNoSession validity in hours. Default: 8.
LOGIN_RATE_LIMITNoMax login attempts per window. Default: 5. Set 0 to disable.
LOGIN_RATE_WINDOWNoRate limit window duration. Default: 1m.
Login rate limiting is per instance (in-memory). In multi-instance deployments, use a shared limiter if you need global enforcement.
TRUSTED_PROXIESNoTrusted proxy IPs/CIDRs for X-Forwarded-For handling. Comma-separated.
MAX_REQUEST_BYTESNoMax request body size in bytes. Default: 2097152.
SSE_MAX_CHANNELSNoMax channels per SSE connection. Default: 8.
SSE_MAX_CLIENTSNoMax concurrent SSE clients per database. Default: 1000.
SSE_CLIENT_BUFFERNoSSE per-client buffer size (messages). Default: 64.
SSE_SEND_TIMEOUTNoMax time to wait when sending to a slow client. Default: 2s.
SSE_HEARTBEATNoHeartbeat interval for SSE connections. Default: 20s.
SSE_IDLE_TIMEOUTNoIdle timeout without notifications. Default: 90s.
Logging
LOG_LEVELNoVerbosity: DEBUG, INFO, WARN, ERROR. Default: INFO.
LOG_OUTPUTNoWhere to write logs: stdout or file path.

Start the server:

./pgarachne -config .env