SSH tunnel or direct TCP for PhpStorm database data source
0 reputation · 15 Feb 2024, 11:51 UTC
0 reputation · 15 Feb 2024, 11:51 UTC
Configuring a PhpStorm Database tool window data source for a database host that is not directly reachable from the developer workstation. PhpStorm supports routing through an SSH tunnel on a bastion host or using direct TCP when the database port is reachable over the network or VPN. Tunnel settings are stored per data source, while SSH configurations can be reused across data sources. Menu paths and option names may differ by PhpStorm release.
Is an SSH tunnel the appropriate choice when only the bastion can reach the database port, and can one SSH configuration be reused for multiple PhpStorm data sources?
37775 reputation · 15 Feb 2024, 23:21 UTC
Yes—when the database port is reachable only from the bastion host, an SSH tunnel is the appropriate choice. Direct TCP is viable only when the workstation already has a network route to the database port, such as through a VPN or a direct subnet.
Yes—the underlying SSH connection configuration can be defined once and reused for multiple data sources. PhpStorm stores tunnel settings per data source, but the SSH configuration itself is a shared IDE-level resource.
If the database port is isolated to the bastion, a direct TCP connection from the workstation will fail because no route exists. The SSH tunnel encapsulates the database connection inside an authenticated session to the bastion, which then forwards traffic to the internal database host. This keeps the database port unexposed to the developer network while still allowing IDE access.
localhost or an internal DNS name), not the bastion’s external address.Before blaming the IDE, verify the bastion permits port forwarding with a scoped command:
ssh -N -L 63306:db-internal.example.com:3306 [contact removed]
If this succeeds, PhpStorm’s tunnel should work with the same parameters. If it fails or hangs, the bastion likely disallows forwarding for that port or user.
Menu paths and option names differ across PhpStorm releases. The SSH tab may appear under Connection, Options, or SSH/SSL depending on the database driver and IDE version. The reuse behavior—selecting a previously configured SSH connection from a dropdown—has remained consistent in recent releases, but exact labels should be confirmed in your installed version.
If a VPN or firewall rule later makes the database port directly reachable, switch the data source to direct TCP. This removes the bastion as a dependency and simplifies connection management, but it is not applicable while the port is isolated to the bastion.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.