Can I Set My Database Hostname as ‘localhost’?

Author:

Published:

Updated on August 15, 2024

Reading Time: 1 min read

The answer to this question depends on the platform type that you are using at StackCP!

StackCP Cloud, AWS, and GCP Cloud Servers #

Yes, ‘localhost’ can be used as the database hostname on all Cloud Servers. Unlike our shared hosting platform types, a Cloud Server runs all services on the same single server, including MySQL. This means that ‘localhost’ can be used as the database hostname.

Linux, WordPress, Windows, and Managed VPS Platforms #

No, you need to set the database hostname as the server it’s on within StackCP.

To find this:

  1. Go to the MySQL Databases icon within a package.
  2. The hostname you’ll need to use will be something similar to shareddb1b.hosting.stackcp.net, although it’s likely the database name on your package will be different.

‘localhost’ generally means the MySQL databases are hosted on the same server as the websites, which is common in the web hosting industry with hosts that have a ‘single-server’ approach where all services run from the same machine.

However, at StackCP and CP CLOUD HOSTING, we split all services and have a strict ‘one server, one rule’ policy. At the StackCP data centres, web traffic, MySQL traffic, and storage are all on physically different machines, so ‘localhost’ doesn’t work.