diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b99cb3d..cc7358b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ Pre-1.0 note: while `pg_durable` is in major version `0`, minor releases may inc
## [0.2.7] - Unreleased
+### Added
+
+- **`pg_durable.host` (#360):** a postmaster GUC that selects the PostgreSQL host used by every connection pg_durable creates. When empty or unset, `PGHOST` is used, falling back to `127.0.0.1`.
+
## [0.2.6] - 2026-08-23
### Added
diff --git a/USER_GUIDE.md b/USER_GUIDE.md
index 053be94f..7d6581cf 100644
--- a/USER_GUIDE.md
+++ b/USER_GUIDE.md
@@ -23,10 +23,11 @@ pg_durable is a PostgreSQL extension that brings durable, fault-tolerant functio
13. [Visualizing Functions](#visualizing-functions)
14. [Monitoring](#monitoring)
15. [User Isolation & Privileges](#user-isolation--privileges)
-16. [Connection Limits](#connection-limits)
-17. [Troubleshooting](#troubleshooting)
-18. [Quick Reference Card](#quick-reference-card)
-19. [Appendix: Test Data Setup](#appendix-test-data-setup)
+16. [Connection Host](#connection-host)
+17. [Connection Limits](#connection-limits)
+18. [Troubleshooting](#troubleshooting)
+19. [Quick Reference Card](#quick-reference-card)
+20. [Appendix: Test Data Setup](#appendix-test-data-setup)
---
@@ -2196,6 +2197,18 @@ SELECT df.grant_usage('app_role');
---
+## Connection Host
+
+Set `pg_durable.host` in `postgresql.conf` to override the host for every PostgreSQL connection created by pg_durable:
+
+```ini
+pg_durable.host = '/var/run/postgresql'
+```
+
+This postmaster setting requires a PostgreSQL restart. When it is empty or unset, pg_durable uses `PGHOST`, falling back to `127.0.0.1` when `PGHOST` is also unset.
+
+---
+
## Connection Limits
pg_durable uses multiple PostgreSQL connections for different purposes. Four GUCs let you control the connection budget to match your deployment's resources.
diff --git a/docs/security-review/workbook-data.md b/docs/security-review/workbook-data.md
index 1cd57db3..4d054059 100644
--- a/docs/security-review/workbook-data.md
+++ b/docs/security-review/workbook-data.md
@@ -115,13 +115,14 @@ pg_durable does not use token-based authentication. All identity is PostgreSQL r
|---|---|---|---|
| `pg_durable.worker_role` | "postgres" | Postmaster | Determines background worker's PostgreSQL identity; must be superuser |
| `pg_durable.database` | "postgres" | Postmaster | Target database for extension operations |
+| `pg_durable.host` | unset | Postmaster | Overrides `PGHOST` for all connections created by pg_durable |
| `df.in_workflow` | unset | Session | Custom GUC set on worker connections; prevents variable mutation during execution |
### Environment Variables
| Variable | Default | Purpose |
|---|---|---|
-| `PGHOST` | "127.0.0.1" | PostgreSQL host for worker connections |
+| `PGHOST` | "127.0.0.1" | PostgreSQL host when `pg_durable.host` is unset |
| `RUST_LOG` | (unset) | Controls tracing verbosity for worker process |
---
diff --git a/scripts/test-e2e-local.sh b/scripts/test-e2e-local.sh
index aacdb60c..e90d83ed 100755
--- a/scripts/test-e2e-local.sh
+++ b/scripts/test-e2e-local.sh
@@ -56,6 +56,7 @@ declare -a ACTIVE_PHASES=()
DEFAULT_BUILD_PHASES=(
"no-preload"
"standard"
+ "host-guc"
"superuser-guc-off"
"connlimit-backpressure"
"connlimit-timeout"
@@ -67,6 +68,7 @@ DEFAULT_BUILD_PHASES=(
ALL_PHASES=(
"no-preload"
"standard"
+ "host-guc"
"superuser-guc-off"
"connlimit-backpressure"
"connlimit-timeout"
@@ -137,6 +139,9 @@ phase_label() {
standard)
echo "standard suite"
;;
+ host-guc)
+ echo "pg_durable.host precedence"
+ ;;
connlimit-backpressure)
echo "connection limit backpressure"
;;
@@ -172,6 +177,9 @@ phase_for_test() {
17_superuser_guc)
echo "superuser-guc-off"
;;
+ 67_host_guc)
+ echo "host-guc"
+ ;;
44_connection_limit_backpressure)
echo "connlimit-backpressure"
;;
@@ -350,7 +358,11 @@ wait_for_server() {
restart_server() {
stop_server
echo -e "${YELLOW}Starting PostgreSQL...${NC}"
- "$PG_CTL" -D "$DATA_DIR" -l "$LOG_FILE" start >/dev/null 2>&1
+ if [ -n "${SERVER_PGHOST:-}" ]; then
+ PGHOST="$SERVER_PGHOST" "$PG_CTL" -D "$DATA_DIR" -l "$LOG_FILE" start >/dev/null 2>&1
+ else
+ "$PG_CTL" -D "$DATA_DIR" -l "$LOG_FILE" start >/dev/null 2>&1
+ fi
wait_for_server
}
@@ -458,11 +470,16 @@ configure_phase() {
local phase="$1"
ensure_data_dir
+ SERVER_PGHOST=""
# Clear stale ALTER SYSTEM overrides from prior phases/runs.
: > "$DATA_DIR/postgresql.auto.conf"
set_conf_line "port" "$PG_PORT"
clear_connlimit_gucs
remove_conf_key "log_connections"
+ remove_conf_key "pg_durable.host"
+ # Match scripts/pg-common.sh so the shared pgrx cluster keeps a usable socket
+ # directory for `make installcheck` after an E2E run.
+ set_conf_line "unix_socket_directories" "'$PGRX_HOME'"
case "$phase" in
no-preload)
@@ -475,6 +492,14 @@ configure_phase() {
set_conf_line "pg_durable.enable_superuser_instances" "on"
set_conf_line "log_connections" "on"
;;
+ host-guc)
+ set_conf_line "shared_preload_libraries" "'pg_durable'"
+ set_conf_line "pg_durable.worker_role" "'postgres'"
+ set_conf_line "pg_durable.database" "'postgres'"
+ set_conf_line "pg_durable.host" "'$PGRX_HOME'"
+ set_conf_line "pg_durable.enable_superuser_instances" "on"
+ SERVER_PGHOST="does-not-resolve.invalid"
+ ;;
superuser-guc-off)
set_conf_line "shared_preload_libraries" "'pg_durable'"
set_conf_line "pg_durable.worker_role" "'postgres'"
@@ -550,7 +575,7 @@ prepare_phase() {
http-allow-all)
build_extension_http_allow_all
;;
- no-preload|standard|superuser-guc-off|connlimit-backpressure|connlimit-timeout|connlimit-startup|reconcile)
+ no-preload|standard|host-guc|superuser-guc-off|connlimit-backpressure|connlimit-timeout|connlimit-startup|reconcile)
# Rebuild if previous phase changed the Cargo features
if [ "$CURRENT_FEATURES" != "http-allow-test-domains" ]; then
build_extension
@@ -600,7 +625,7 @@ prepare_phase() {
wait_for_worker_ready
fi
;;
- connlimit-backpressure|connlimit-timeout)
+ host-guc|connlimit-backpressure|connlimit-timeout)
ensure_e2e_role
wait_for_worker_ready
;;
diff --git a/src/lib.rs b/src/lib.rs
index 11736117..08826a7e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,6 +20,8 @@ pub static WORKER_ROLE: GucSetting