You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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.100 or my-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 localhost or 127.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., root or 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 600 permissions with chmod 600 ~/.ssh/id_rsa if 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: localhost or 127.0.0.1 (matches DB_HOST in your .env)
  • Port: Your database port (usually 3306 for MySQL, 5432 for PostgreSQL—matches DB_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 from localhost (MySQL uses user@localhost permissions 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 07:43:12