phacility/phabricator · error · Exception
Unable to test remote address against cluster whitelist: REM
Error message
Unable to test remote address against cluster whitelist: REMOTE_ADDR is not defined or not valid.
What it means
PhabricatorEnv::isClusterRemoteAddress() decides whether the current client is a cluster node: if `cluster.addresses` is configured it must classify the peer, which requires a remote address. getRemoteAddress() reads REMOTE_ADDR (honoring trusted proxy headers); when it is absent or unparseable - typically in CLI/daemon contexts where no HTTP peer exists - classification is impossible and the method throws instead of guessing. Failing closed here is deliberate: cluster auth decisions must not default to trust.
Source
Thrown at src/infrastructure/env/PhabricatorEnv.php:873
*
* @param string IP address.
* @return bool True if the address is blacklisted.
*/
public static function isBlacklistedOutboundAddress($address) {
$blacklist = self::getEnvConfig('security.outbound-blacklist');
return PhutilCIDRList::newList($blacklist)->containsAddress($address);
}
public static function isClusterRemoteAddress() {
$cluster_addresses = self::getEnvConfig('cluster.addresses');
if (!$cluster_addresses) {
return false;
}
$address = self::getRemoteAddress();
if (!$address) {
throw new Exception(
pht(
'Unable to test remote address against cluster whitelist: '.
'REMOTE_ADDR is not defined or not valid.'));
}
return self::isClusterAddress($address);
}
public static function isClusterAddress($address) {
$cluster_addresses = self::getEnvConfig('cluster.addresses');
if (!$cluster_addresses) {
throw new Exception(
pht(
'This server is not configured to serve cluster requests. '.
'Set `cluster.addresses` in the configuration to whitelist '.
'cluster hosts before sending requests that use a cluster '.
'authentication mechanism.'));
}View on GitHub (pinned to 5720a38cfe)
Solutions
- Only invoke cluster-auth paths within a real web request; for CLI code, branch on php_sapi_name() !== 'cli' before calling isClusterRemoteAddress().
- Fix the edge network: ensure REMOTE_ADDR reaches PHP (LB in HTTP mode, or configure trusted-proxy headers so getRemoteAddress() can recover the client address).
- Check `cluster.addresses` is actually intended - if this host is not part of a cluster, removing the config removes the requirement.
Example fix
// before
$is_cluster = PhabricatorEnv::isClusterRemoteAddress(); // throws in CLI
// after
if (php_sapi_name() === 'cli') {
$is_cluster = false; // no remote peer exists on the command line
} else {
$is_cluster = PhabricatorEnv::isClusterRemoteAddress();
} Defensive patterns
Strategy: type-guard
Validate before calling
if (php_sapi_name() === 'cli' && PhabricatorEnv::getEnvConfig('cluster.addresses')) {
// no REMOTE_ADDR exists on the CLI; do not call isClusterRemoteAddress()
return false;
} Type guard
function hasClassifiableRemoteAddress() {
if (php_sapi_name() === 'cli') {
return false;
}
return (bool) PhabricatorEnv::getRemoteAddress();
} Try / catch
try {
$trusted = PhabricatorEnv::isClusterRemoteAddress();
} catch (Exception $ex) {
// fail closed: unknown peer is never treated as cluster
$trusted = false;
phlog($ex); // but surface the misconfiguration loudly
} Prevention
- Gate cluster-auth code on web context; daemons and scripts have no peer address.
- Ensure your load balancer terminates HTTP and always sets REMOTE_ADDR, or configure trusted proxies.
- Fail closed and log when classification is impossible - never default to trusted.
When it happens
Trigger: Calling PhabricatorEnv::isClusterRemoteAddress() from a script, daemon, or worker (no REMOTE_ADDR), or from a web request where a misconfigured load balancer strips REMOTE_ADDR and no trusted X-Forwarded-For handling recovers it, while `cluster.addresses` is non-empty.
Common situations: Running bin scripts on a clustered install (cluster.addresses set) after an upgrade introduced cluster-auth checks into that code path; load balancers in TCP mode not setting REMOTE_ADDR; unit tests invoking cluster auth logic outside a request.
Related errors
- This server is not configured to serve cluster requests. Set
- Request parameter "%s" is not formatted properly. Expected a
- Request parameter "%s" is not formatted properly. Expected a
- Invalid Request (CSRF)
- This server is configured as "%s", but you are using the dom
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/52f9116e6ab694fd.
Report an issue: GitHub.