Skip to content

Connecting to databases

Once you’ve installed a database and started a service (see Databases & services), your app connects to it on local development with permissive local auth, so there’s nothing to configure before you connect.

For an instance added with --tcp, connect on 127.0.0.1 with these defaults:

ServiceHostPortUsernamePassword
MySQL127.0.0.13306root(empty)
MariaDB127.0.0.13307root(empty)
PostgreSQL127.0.0.15432postgres(empty)
Redis127.0.0.16379(none)
Valkey127.0.0.16380(none)
MongoDB127.0.0.127017(none)
Mailpit (SMTP)127.0.0.11025(none)
Mailpit (web inbox)127.0.0.18025
Typesense127.0.0.18108API keybutler

A typical Laravel .env against Butler’s MySQL:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_app_local
DB_USERNAME=root
DB_PASSWORD=

For PostgreSQL, use DB_CONNECTION=pgsql, port 5432, and username postgres.

Catch outgoing mail with Mailpit:

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025

Every message your app sends then shows up in Mailpit’s web inbox at http://127.0.0.1:8025 instead of going to a real recipient.

Point Redis at the cache/queue:

REDIS_HOST=127.0.0.1
REDIS_PORT=6379

Instead of creating a database by hand, let Butler create and wire one up when you link the project. Add it to the project’s butler.yml:

database:
type: mysql
name: my_app_local
createOnLink: true

On butler link, Butler creates my_app_local (if it doesn’t exist) so your app connects straight away.

If you use the app, the Sites section can open a linked site’s database directly in a GUI such as TablePlus — Butler reads the credentials from the project’s .env and hands them off, so you don’t retype host, port and password. From the Services section you can also open or copy a connection string for a running database instance.

For lower-overhead local connections, a service can run in unix-socket mode instead of TCP. When it does, point your app at the socket path (Butler shows it in the service’s connection details) rather than a host and port — for MySQL and PostgreSQL that’s DB_SOCKET, and for Redis, Butler rewrites the host/port to the socket automatically in copied .env snippets.