TablePlus新手求助:连接Laravel数据库的SSH配置问题及Host与Server地址混淆疑问
Hey there! I get why this is confusing at first—SSH connections add an extra layer that mixes up "host" terms. Let's clear this up and walk you through connecting your Laravel database with TablePlus step by step.
Understanding Host vs. Server in SSH Connections
When using SSH tunneling in TablePlus, these two fields serve completely different purposes:
- Host (SSH Host): This is the public address of your remote server (the one you SSH into directly—like a VPS IP or domain name, e.g.,
192.168.1.100ormy-laravel-server.com). It's where your Laravel app and database are hosted. - Server (Database Host): This is the address of your database from the perspective of the SSH server. Since most Laravel setups run the database locally on the same server as the app, you'll almost always fill this with
localhostor127.0.0.1—not the public IP of your server. This is the key distinction that trips up most beginners!
Step-by-Step Configuration for Laravel + TablePlus Over SSH
Let's map this directly to your Laravel .env file values to avoid mistakes:
1. Set Up the SSH Tunnel
First, fill out the SSH section in TablePlus's connection window:
- Host: Your server's public IP/domain (the one you use to SSH via terminal, e.g.,
ssh user@your-server-ip) - User: Your SSH login username (e.g.,
rootor a dedicated server user) - Authentication: Use either your SSH password or a private key file (keys are more secure—make sure your local key has
600permissions withchmod 600 ~/.ssh/id_rsaif you go this route) - Port: Default is
22; only change this if you've modified your server's SSH port
2. Configure the Database Connection
Next, fill the database section using values from your Laravel .env file:
- Server:
localhostor127.0.0.1(matchesDB_HOSTin your.env) - Port: Your database port (usually
3306for MySQL,5432for PostgreSQL—matchesDB_PORT) - Database: Your Laravel database name (matches
DB_DATABASE) - User: Database username (matches
DB_USERNAME) - Password: Database password (matches
DB_PASSWORD)
Troubleshooting Common Errors
Since you mentioned hitting errors, here are quick fixes for the most common issues:
- "Connection refused" (SSH): Check if your server's firewall allows incoming traffic on port 22, and verify your SSH host/port are correct.
- "Access denied for user" (Database): Confirm your database credentials match exactly what's in
.env, and ensure the database user has permissions to connect fromlocalhost(MySQL usesuser@localhostpermissions by default). - "Can't reach database server": Double-check you set the Database Server to
localhost—using the public IP here will fail because most databases aren't exposed directly to the internet.
内容的提问来源于stack exchange,提问作者opia austin
相关产品推荐
相关产品推荐

