Skip to content

Connect your app to a database

Once you’ve created a database, your app needs four things: host, port, database name, and user/password. On OrbixPanel the app and database share a server, so you always connect over localhost.

DatabaseHostPort
MySQL / MariaDB127.0.0.13306
PostgreSQL127.0.0.15432

Keep credentials in environment variables, never in code you commit.

WordPress (wp-config.php)

define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'myapp');
define('DB_USER', 'myappuser');
define('DB_PASSWORD', getenv('DB_PASSWORD'));

Laravel (.env)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=myappuser
DB_PASSWORD=•••••

Django (settings.py)

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ["DB_NAME"],
"USER": os.environ["DB_USER"],
"PASSWORD": os.environ["DB_PASSWORD"],
"HOST": "127.0.0.1",
"PORT": "5432",
}
}

Node.js

// MySQL (mysql2)
const db = await mysql.createConnection({
host: '127.0.0.1', port: 3306,
user: process.env.DB_USER, password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});
// PostgreSQL (pg) — connection string
// postgres://USER:PASSWORD@127.0.0.1:5432/DBNAME

Why 127.0.0.1 and not a public host?

Your database isn’t exposed to the internet (and shouldn’t be — see the firewall guide). Apps reach it on localhost, which is faster and far safer than a public database endpoint.

Troubleshooting

  • “Access denied” → wrong user/password, or the user wasn’t granted access to that database.
  • “Connection refused” → wrong port, or you used an external host instead of 127.0.0.1.

Running OrbixPanel? Databases connect locally and securely by default. OrbixPanel.com → — the free, self-hosted, AI-powered hosting control panel.