Prevent LocalWP from editing config.php or updating constants?

Is it possible to prevent LocalWP from editing wp-config.php when it does a pull? Or something similar that would help here…

My wp-config.php file is deliberately version controlled.

I use a .env file (dotenv) and $_ENV['DB_NAME'] to set the constants within wp-config.php. When LocalWP does a pull it tries to update these values and frankly breaks the whole thing.

Does anyone know if it’s possible to prevent Local from either updating some constants or editing the file altogether?

Thank you


  • wp-config.php is already in the .wpe-pull-ignore file
  • I swear this didn’t used to happen but I couldn’t say when this behaviour changed

Hi @benrich!

Are you pulling from WP-Engine specifically? Because this only works with WPE and not with Flywheel if you’ve got sites on both or only on FW.

If you’re on WP Engine, make sure your .wpe-pull-ignore file is in your /app/public/ directory, and then Local should ignore any files/paths provided there.

You can also see all of the auto-ignored files on this link here:

Local Connect Path Exclusions

If you’re still having trouble, can you share some additional details with us?

  • OS/OS version
  • Local Version
  • Is this happening on a specific install or for multiple installs?
  • Please add a copy of your Local Logs: Retrieving Local’s Log File

Thank Nick.

Here are some more things to help clarify things:

  • yes, WP Engine exclusively
  • .wpe-pull-ignore is in the correct location and successfully ignores other folders/files
  • wp-config.php is listed within .wpe-pull-ignore (like other files that are ignored)
  • I notice wp-config.php is also listed in the automatically ignored files that you referred to
  • Yep, happens with multiple installs on many machines (2x MacOS)
  • Local v9.2.3+6776 (no updates available)
  • local-logs.zip (225.5 KB)

What I assume is happening is, as part of LocalWP’s processes when pulling, it searches wp-config.php for the constants (and their values) it needs for the website to run normally. If it doesn’t see what it expects then it add/updates the constants.

If that’s true, it’s this action that’s breaking my setup and what I’d like to prevent.


For extra clarity, these are the changes it makes. It doesn’t realise that the DB consts are already set. Then god knows what it’s doing with WP_HOME & WP_SITEURL before commenting them out.

I realise this is quite an edge case and I can just checkout the changes with git on each pull. But, you know, developers love removing manual tasks. Plus, versioning this file can’t be all that uncommon. Perhaps there’s a solution or workaround out there.

Thanks again

Hey @benrich!

I checked with the Local Devs and looking at the code that updates the WP_HOME and WP_SITEURL constants, that part of Local core hasn’t changed in several years. I know you had mentioned you didn’t think this used to be an issue but we’re just a bit stumped when something may have changed that impacted this. It seems like Local isn’t necessarily editing the wp-config.php file but ignoring it and generating a new one when pulling.

For now at least, you might be correct in that incorporating Git will be the best way to ensure nothing is getting broken.

Ok, I’ll just continue using git to checkout the changes made by Local.

Also, I think it’s best to disregard what I said here. On reflection I’m not sure now:

I swear this didn’t used to happen but I couldn’t say when this behaviour changed

Perhaps if there’s an elegant way to stop the wp-config.php file from being updated, that would be a nice addition to the software :slight_smile: . Especially useful for when files are version controlled.

Anyway, thank you for looking into it.

2 Likes

Okay sounds good thank you for following up and the feedback @benrich! I’ll pass this along to our Local team. Happy Developing :green_heart: