Each database has a host, a port, a name, and credentials. Find them on your project’s Databases page.
Connection details
From the Databases page, copy the host, port, database name, and user. The password is shown once — store it in your environment variables rather than in code.
Example: connecting to PostgreSQL from Django
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "my_database",
"USER": "my_user",
"PASSWORD": os.environ["DB_PASSWORD"],
"HOST": os.environ["DB_HOST"],
"PORT": os.environ["DB_PORT"],
}
}
Example: MySQL from Laravel
DB_CONNECTION=mysql
DB_HOST=$DB_HOST
DB_PORT=$DB_PORT
DB_DATABASE=$DB_DATABASE
DB_USERNAME=$DB_USERNAME
DB_PASSWORD=$DB_PASSWORD
Redis
Redis connects the same way with a host and port — perfect for caching sessions and queues.
Security note
Use environment variables for credentials. Never commit database passwords to your repository.