# WP-CLI Doesn't Work with Modified WP-Config

**URL:** <https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055>\
**Category:** Support\
**Created:** [April 19, 2019, 6:07pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055 "2019-04-19T18:07:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyenglert](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@jeremyenglert](https://community.localwp.com/u/jeremyenglert)\
**Post date:** [April 19, 2019, 6:07pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/1 "2019-04-19T18:07:32Z")

</div>

We use a wp-config-local.php for our local environments. The wp-config.php automatically loads wp-config-local.php if it exists. This works fine, except when we try to run WP-CLI commands.

When we attempt to run a WP-CLI command, we get an error about a database connection.

When I look at the “Database” tab in local, it is unable to find most of the values because it is looking in wp-config.php (instead of wp-config-local.php).

Is there a way to tell Local to use wp-config-local.php? Or another work around for this?

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [April 19, 2019, 9:26pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/2 "2019-04-19T21:26:02Z")

</div>

Hey @jeremyenglert –

Can you provide a little more info on what’s going wrong?

- Do you have the exact connection error that is being reported?
- Where is the wp-cli command being run - on the host machine, or inside the container?

---

<div class="post-metadata">

**Author:** ![jeremyenglert](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@jeremyenglert](https://community.localwp.com/u/jeremyenglert)\
**Post date:** [April 19, 2019, 9:53pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/3 "2019-04-19T21:53:57Z")

</div>

Hi Ben!

Here is the error output:

```auto
Last login: Fri Apr 19 14:50:24 on ttys000
Jeremys-MacBook-Pro:~ jeremyenglert$ /Users/jeremyenglert/Library/Application\ Support/Local\ by\ Flywheel/ssh-entry/Bykr6g7j7.sh ; exit;
root@f5c5dbc1a772:/# wp info

Fatal error: Cannot redeclare wp_get_server_protocol() (previously declared in /app/public/wp-includes/load.php:15) in /app/public/wp-includes/load.php on line 21

Call Stack:
    0.0001 345408 1. {main}() /usr/local/bin/wp:0
    0.0105 750640 2. include('phar:///usr/local/bin/wp/php/boot-phar.php') /usr/local/bin/wp:4
    0.0106 757584 3. include('phar:///usr/local/bin/wp/php/wp-cli.php') phar:///usr/local/bin/wp/php/boot-phar.php:8
    0.0108 767680 4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
    0.0612 6780512 5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
    0.0612 6780552 6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
    0.0663 6858288 7. WP_CLI\Runner->load_wordpress() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1032
    5.4033 63964760 8. require('/app/public/wp-settings.php') phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1105

root@f5c5dbc1a772:/# 

```

This is being run inside the container (SSHing into the install).

---

<div class="post-metadata">

**Author:** ![ben.turner](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/ben.turner/32/5366_2.png) [@ben.turner](https://community.localwp.com/u/ben.turner)\
**Post date:** [April 19, 2019, 10:32pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/4 "2019-04-19T22:32:44Z")

</div>

@jeremyenglert –

Can you take a look at this Github issue:

- [WP-CLI can fail cryptically when parsing custom wp-config.php · Issue #1631 · wp-cli/wp-cli · GitHub](https://github.com/wp-cli/wp-cli/issues/1631)

and in particular this comment from that issue:

- [WP-CLI can fail cryptically when parsing custom wp-config.php · Issue #1631 · wp-cli/wp-cli · GitHub](https://github.com/wp-cli/wp-cli/issues/1631#issuecomment-173314103)

> I simply commented out `require_once(ABSPATH . 'wp-settings.php');` in `wp-config-local.php` (and left it as-is in `wp-config.php` ). This solved my wp-cli problem and doesn’t appear (so far) to have any adverse effects (since `wp-settings.php` does still get loaded in `wp-config.php` )

Let me know if that fixes things for you.

---

<div class="post-metadata">

**Author:** ![jeremyenglert](https://avatars.discourse-cdn.com/v4/letter/j/a4c791/32.png) [@jeremyenglert](https://community.localwp.com/u/jeremyenglert)\
**Post date:** [April 20, 2019, 7:51am UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/5 "2019-04-20T07:51:45Z")

</div>

That appears to fix the issue! Big thanks Ben!

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/system/32/1_2.png) [@system](https://community.localwp.com/u/system)\
**Post date:** [June 12, 2019, 10:00pm UTC](https://community.localwp.com/t/wp-cli-doesnt-work-with-modified-wp-config/12055/6 "2019-06-12T22:00:54Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
