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
MySQL
instances. Whether your database is exposed to the public internet or tucked behind a private
VPC
, the connection strategy changes significantly to maintain security without sacrificing accessibility.

Prerequisites

Before attempting these connections, ensure you have the following:

  • A
    Laravel Vapor
    account with an active database.
  • TablePlus
    or a similar database management tool installed locally.
  • Basic familiarity with
    SSH
    keys and terminal commands.
  • An existing Network configured within the
    Vapor UI
    .

Key Libraries & Tools

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
AWS
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
VPC
and acts as an intermediary.

First, create the jump box in the

under Resources > Networks. Vapor generates a private
SSH
key; save this strictly on your local machine. In
TablePlus
, switch the connection type to MySQL over SSH. You must provide both the database credentials and the jump box
SSH
details (Server IP and the private key path).

Syntax Notes & Best Practices

  • Host Resolution: Never hardcode these hosts; always pull them from the
    Vapor UI
    as they can change during migrations.
  • User Defaults: Vapor creates a master user named vapor by 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
SSH
tunnel useless. For private databases, ensure you are connecting to the database name vapor to see your tables immediately after connecting.

3 min read