Guides › HTML / PHP sites › Site down or error screens

PHP Database Connection Errors (mysqli and PDO): Access Denied, Unknown Database, Connection Refused

Read the exact message and match it to the cause: credentials, host, database name or server down.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Site down or error page

Print or log the exact error. Each message points to a different cause.

Common messages

Steps

  1. In your hosting panel, check the database name, user and that the user is assigned to the database with privileges.
  2. Use the host name your provider documents. It is often localhost, but some hosts use a different name.
  3. Reset the database user's password and update your code.
  4. Test with a tiny script using the same details.
  5. Do not show errors to visitors on a live site. See our PHP errors guide.

WordPress

See our WordPress database connection guide.

Security

Keep database credentials out of public files, and use prepared statements for queries.

Free tool for this problem: Database Checker

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-21.