Mastering Laravel Vapor: Local Connections to Public and Private Databases
Overview
Managing databases requires more than just checking a UI; developers need direct access to data for debugging and local development. This tutorial breaks down the technical workflow for bridging the gap between your local environment and cloud-hosted instances. Whether your database is exposed to the public internet or tucked behind a private , the connection strategy changes significantly to maintain security without sacrificing accessibility.
Prerequisites
Before attempting these connections, ensure you have the following:
- A account with an active database.
- or a similar database management tool installed locally.
- Basic familiarity with keys and terminal commands.
- An existing Network configured within the .
Key Libraries & Tools
- : The serverless deployment platform for .
- : A modern, native tool for managing multiple databases like and .
- : A small, low-cost server acting as a secure gateway into a private network.
Connecting to Public Databases
Public databases are the simplest to configure because they allow direct traffic. Within the , navigate to your database card to retrieve the Host, User (defaulting to vapor), and Password.
// Connection Parameters for TablePlus
{
"engine": "MySQL",
"name": "My Public DB",
"host": "your-db-instance.aws.com",
"user": "vapor",
"port": 3306
}
Simply input these credentials into . Always test the connection to confirm the firewall rules in permit your local IP.
The Jump Box Strategy for Private Databases
Private databases live inside a network that refuses direct outside connections. To bypass this, we use a . This instance sits inside your and acts as an intermediary.
First, create the jump box in the under Resources > Networks. Vapor generates a private key; save this strictly on your local machine. In , switch the connection type to MySQL over SSH. You must provide both the database credentials and the jump box details (Server IP and the private key path).
Syntax Notes & Best Practices
- Host Resolution: Never hardcode these hosts; always pull them from the as they can change during migrations.
- User Defaults: Vapor creates a master user named
vaporby default, but you should create restricted users for production environments. - SSH Security: Keep your jump box keys out of version control. Treat them with the same sensitivity as your root passwords.
Tips & Gotchas
If a connection fails, check your security groups. A common mistake is failing to place the jump box and the database in the same network. Without shared network proximity, the jump box cannot see the database, rendering the tunnel useless. For private databases, ensure you are connecting to the database name vapor to see your tables immediately after connecting.
- 16%· products
- 16%· products
- 16%· products
- 12%· products
- 12%· products
- Other topics
- 28%

Learn Laravel Vapor #17: Connecting To Databases Locally
WatchLaravel // 7:43
The official YouTube channel of Laravel, the clean stack for Artisans and agents. We will update you on what's new in the world of Laravel, from the framework to our products Cloud, Forge, and Nightwatch.