Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

The WordPress setup wizard stops because a wp-config.php is already there

Your error

The file wp-config.php already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.1 more line it can show

Fix it fast

Most common cause, 1 of 2

wp-config.php is already in the WordPress folder

If the values in the file are right, finish the install at wp-admin/install.php, which is the link in the message.

Fix
# continue with the existing file
# https://example.com/wp-admin/install.php

# or rerun the wizard, keeping a copy
mv wp-config.php wp-config.php.bak
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

WordPress shows The file wp-config.php already exists when wp-admin/setup-config.php runs while a wp-config.php sits in the WordPress folder or one level above it. The wizard only creates that file and never overwrites it. Continue at wp-admin/install.php, or edit the database values in the file by hand. Remove it only to rerun the wizard. Applies to WordPress 7.1.

  • Applies to WordPress 7.1 (7.1.5 current)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

In the WordPress folder (the one that holds wp-settings.php), list both places the wizard checks. Which of the two has a wp-config.php decides the cause.

Run this first
ls -l wp-settings.php wp-config.php
ls -l ../wp-config.php ../wp-settings.php

Then find the line you see in this list and open its fix:

  1. 1wp-config.php is already in the WordPress folderls finds wp-config.php next to wp-settings.php, and the message has no one level above part
  2. 2A wp-config.php sits one folder above the WordPress installThe message says one level above your WordPress installation, and ../wp-config.php exists while ../wp-settings.php does not

What does the error look like?

  • The file wp-config.php already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.
  • The file wp-config.php already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.

Cause 1 of 2

wp-config.php is already in the WordPress folder

You seels finds wp-config.php next to wp-settings.php, and the message has no one level above part

Check

The setup wizard's first test is whether a wp-config.php exists in the WordPress folder. If it does, setup-config.php stops with this message and leaves the file untouched. You land there after creating the file by hand from wp-config-sample.php and then clicking the wizard link, after a host installer wrote the file for you, or after copying a site whose old file came along.

Check
grep -nE "DB_NAME|DB_USER|DB_HOST|table_prefix" wp-config.php

Fix

If the values in the file are right, finish the install at wp-admin/install.php, which is the link in the message. If they are wrong, edit them in the file. Only when you want the wizard to write a new file, move the current one aside first instead of deleting it.

Fix
# continue with the existing file
# https://example.com/wp-admin/install.php

# or rerun the wizard, keeping a copy
mv wp-config.php wp-config.php.bak

Verify

After the install, the home page answers with status 200 instead of a setup screen.

Verify
curl -sI https://example.com/ | head -n 1

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 2

A wp-config.php sits one folder above the WordPress install

You seeThe message says one level above your WordPress installation, and ../wp-config.php exists while ../wp-settings.php does not

Check

WordPress supports keeping wp-config.php one directory above the install. wp-load.php uses that parent file whenever the folder itself has none and the parent folder holds no wp-settings.php of its own. A fresh WordPress unpacked into a subfolder such as /blog therefore picks up a leftover parent file, connects to that file's database, and if you open the setup wizard it refuses to write a new one.

Check
grep -nE "DB_NAME|DB_HOST" ../wp-config.php

Fix

Give this install its own file: copy wp-config-sample.php to wp-config.php in the WordPress folder and fill in its database values. WordPress reads a file in its own folder before it looks one level up. Move the parent file away only if no other site uses it.

Fix
cp wp-config-sample.php wp-config.php
# edit DB_NAME, DB_USER, DB_PASSWORD and DB_HOST, then open /wp-admin/install.php

Verify

This folder now holds its own config file, and install.php for this path shows the install form.

Verify
ls -l wp-config.php ../wp-config.php

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Change database settings by editing wp-config.php; the wizard only writes a missing file.
  • Before installing WordPress in a subfolder, check the folder above for an old wp-config.php.
  • Keep wp-config.php readable only by you and the web server (mode 400 or 440), as the WordPress hardening guide advises.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Spotless Laundry, EZ Estimater.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.