Where Does Perforce Store Connection Settings?
Perforce reads P4PORT, P4USER, and P4CLIENT from P4CONFIG files upward, env vars, and the Windows registry.
Last updated
Perforce has no single settings file. It searches the current directory and every parent for the filename stored in P4CONFIG, commonly .p4config or p4config.txt, and uses the values it finds. That lets each workspace carry its own server, user, and client names.
The search order is fixed: command line flags win, then the nearest P4CONFIG file, then environment variables, then the P4ENVIRO file, then the Windows registry. Running p4 set with no arguments shows every value and exactly where each one came from, which ends most confusion in one command.
Where Perforce Helix Core stores this, by platform
HKEY_CURRENT_USER\Software\Perforce\Environment
Values written by p4 set for the current user. Use p4 set -s for machine-wide defaults in HKEY_LOCAL_MACHINE. P4CONFIG files in workspace folders override both. Run bare p4 set to see each value's source.
<workspace>/.p4config (found by upward search)
Set P4CONFIG to a filename like .p4config and place one per workspace with P4PORT, P4USER, P4CLIENT lines and no spaces around =. Values from p4 set go to the P4ENVIRO file. Parent directory files fill in anything the nearer ones omit.
<workspace>/.p4config (found by upward search)
Same upward search as Linux. One file per workspace keeps server and client pairs straight when switching projects. Check the active values with p4 set before debugging connection errors.
Frequently asked questions
Why is Perforce using the wrong workspace?
Run p4 set with no arguments. It prints every variable plus its source, so you can see whether a stray P4CONFIG file above your shell or an old registry entry is winning. The nearest config file beats environment and registry every time.
How do I use different servers per project?
Put a P4CONFIG file with P4PORT, P4USER, and P4CLIENT in each workspace root and set P4CONFIG to that filename once. Settings follow your shell as you cd between projects. Shared defaults can sit in a parent directory file.
Notice an outdated path? Let us know.