DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

SSH Tunnel Starts, Database Still Fails: What ExitOnForwardFailure=yes Means

A successful SSH forward setup does not prove the database is reachable. Learn what ExitOnForwardFailure=yes checks and how to test the connection through the tunnel.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ExitOnForwardFailure=yes confirms that OpenSSH could set up the requested port forwarding; it does not confirm that the database can be reached through it. The actual connection to the forwarding destination happens only when an application uses the tunnel. OpenSSH’s manual states that the option “does not apply to connections made over port forwardings.” OpenSSH manual

What the option checks—and what it does not

When you request a local forward, SSH tries to create a listening port on your client. ExitOnForwardFailure=yes makes the SSH client exit if it cannot establish the requested forwarding setup—for example, if it cannot bind that local port. It does not make the SSH server connect to the database in advance or check whether that connection will succeed.

As an Amazon Associate I earn from qualifying purchases.

These are separate events: first SSH sets up the forward; later, an application connects to the local port, and the SSH server attempts to connect to the configured destination. A listener can therefore be active even when the database host or port is unreachable from the SSH server. OpenSSH manual PostgreSQL documentation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where the database connection actually comes from

For a local forward, the destination hostname is reached from the remote SSH side—not from the computer running your database client. That distinction matters when the destination is localhost: it means the SSH server’s loopback interface. If the database runs on that same machine and listens on loopback, this can be the right destination. If the database is a separate machine, use a destination address the SSH server can reach.

For example, PostgreSQL documents this tunnel:

ssh -L 63333:localhost:5432 [email protected]

Here, the SSH server at foo.com is asked to connect to its own localhost:5432 when a client uses local port 63333. The command sets up the forward; it does not itself attempt a PostgreSQL connection. The database client does that:

psql -h localhost -p 63333 postgres

Use the actual SSH host, destination hostname and port, and database settings for your environment. PostgreSQL documentation

Diagnose the failure by layer

Check the point where the connection stops rather than treating a successful SSH command as proof that every later step works.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. SSH connection: Confirm that the client establishes an SSH session with the intended server. A failure here is separate from forwarding or database access.
  2. Forward setup: Confirm the requested local port can be bound and the forward is created. This is the setup stage that ExitOnForwardFailure=yes helps detect.
  3. Destination reachability: Connect a database client to the local forwarded endpoint. This causes the SSH server to attempt the destination connection. If that fails, check whether the SSH server can reach the specified host and port, and whether the address points to the intended machine.
  4. Database protocol and authentication: If the client reaches the database but reports a database-level error, investigate the database settings, user credentials, and server configuration. Successful forward setup alone says nothing about whether a database user can authenticate.

Check the destination address and network leg

Database on the SSH server

If the database is on the SSH server, localhost in the forward destination refers to that server’s loopback interface. A database listening only on loopback may not accept connections addressed to the server’s external hostname; those addresses are not interchangeable.

Database on a separate host

If the database is on another machine, the SSH server must be able to reach that machine and port. The SSH tunnel encrypts traffic between your client and the SSH server. The separate connection from the SSH server to the database host is not encrypted by that tunnel, as PostgreSQL’s guidance notes. PostgreSQL documentation

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What a successful test establishes

Using a database client against the local forwarded port tests more than SSH setup: it exercises the tunnel, the SSH server’s connection to the destination, and the database interaction attempted by that client. Interpret the result according to the reported failure. A successful SSH setup is evidence only that the requested forwarding setup succeeded—not that the destination TCP connection, database service, or authentication will succeed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.