{"id":778,"date":"2026-12-03T20:52:09","date_gmt":"2026-12-03T20:52:09","guid":{"rendered":"https:\/\/getserverexplorer.app\/?p=778"},"modified":"2026-11-29T21:01:43","modified_gmt":"2026-11-29T21:01:43","slug":"how-to-access-a-remote-postgresql-database-over-ssh","status":"publish","type":"post","link":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/","title":{"rendered":"How to Access a Remote PostgreSQL Database over SSH"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Your application runs on a Linux VPS, and its PostgreSQL database is only accessible from the server. Now you need to inspect a table, investigate a bug, or verify a migration from your computer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Opening port 5432 to the internet might seem like the easiest solution. However, an SSH tunnel lets you connect to PostgreSQL without making the database publicly accessible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to access PostgreSQL over SSH using the command line, DBeaver, and an alternative server management workflow with Server Explorer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why access PostgreSQL over SSH?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL commonly listens on port 5432. For applications running on the same server, the database can listen only on the loopback interface, keeping it inaccessible directly from the internet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SSH local port forwarding creates a connection between a port on your computer and a database endpoint reachable from your SSH server. Traffic between your computer and the SSH server travels through an encrypted channel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Local endpoint: <code>127.0.0.1:15432<\/code><\/li>\n\n\n\n<li>SSH server: <code>your-server-ip:22<\/code><\/li>\n\n\n\n<li>Remote PostgreSQL endpoint: <code>127.0.0.1:5432<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Your database client connects to local port 15432. SSH forwards the traffic to PostgreSQL on the VPS. Database authentication still applies: an SSH account does not automatically grant access to database tables.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Check your PostgreSQL installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before creating a tunnel, connect to your VPS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh deploy@your-server-ip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On a typical systemd-based installation, check the service and listening port:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status postgresql\nsudo ss -ltnp | grep ':5432'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The service name may differ depending on your distribution. A listener on <code>127.0.0.1:5432<\/code> is sufficient for the tunnel in this example.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If PostgreSQL accepts local socket connections and you have administrative access, inspect its settings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u postgres psql -c 'SHOW listen_addresses;'\nsudo -u postgres psql -c 'SHOW port;'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You also need a database name, an authorized database user, and its authentication credentials. If SSH itself fails, see this guide to <a href=\"https:\/\/getserverexplorer.app\/index.php\/2026\/11\/08\/ssh-permission-denied-publickey\/\">fixing SSH public-key authentication errors<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Connect to PostgreSQL using an SSH tunnel<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open a terminal on your computer, not inside your existing remote SSH session. With OpenSSH installed, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -N -L 127.0.0.1:15432:127.0.0.1:5432 -o ExitOnForwardFailure=yes deploy@your-server-ip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what the options mean:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Option<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td><code>-N<\/code><\/td><td>Establish a tunnel without running a remote shell<\/td><\/tr><tr><td><code>-L<\/code><\/td><td>Forward a local port to a remote destination<\/td><\/tr><tr><td><code>127.0.0.1:15432<\/code><\/td><td>Listen only on your computer&#8217;s loopback interface<\/td><\/tr><tr><td><code>127.0.0.1:5432<\/code><\/td><td>Reach PostgreSQL from the SSH server<\/td><\/tr><tr><td><code>ExitOnForwardFailure=yes<\/code><\/td><td>Exit if the forwarding listener cannot be established<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Keep this terminal open. If the command produces no output after authentication, that is normally expected.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In another local terminal, connect using the PostgreSQL client:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>psql -h 127.0.0.1 -p 15432 -U app_reader -d app_db<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>app_reader<\/code> and <code>app_db<\/code> with your own account and database. Enter the database password when prompted, then test the connection:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT current_database(), current_user, version();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>q<\/code> to exit psql. Close the SSH tunnel with Ctrl+C when you finish. If your SSH server uses a custom port, add <code>-p<\/code> with that port to the SSH command, not the psql command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Connect to PostgreSQL over SSH with DBeaver<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A graphical database client is useful when you need to browse schemas, inspect records, or write SQL queries regularly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/dbeaver.io\/\">DBeaver<\/a> supports PostgreSQL and SSH tunneling. Create a PostgreSQL connection and configure the main database settings:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Setting<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Database host<\/td><td><code>127.0.0.1<\/code><\/td><\/tr><tr><td>Database port<\/td><td><code>5432<\/code><\/td><\/tr><tr><td>Database<\/td><td><code>myapp_db<\/code><\/td><\/tr><tr><td>Database user<\/td><td><code>myuser<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Enable SSH tunneling in the connection&#8217;s SSH settings. Enter your VPS hostname, SSH port, SSH username, and authentication details. Verify the server host key and test the connection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DBeaver manages the forwarding when its built-in tunnel is enabled. Alternatively, you can leave that option disabled and connect to <code>127.0.0.1:15432<\/code> using the manual tunnel from the previous section.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Avoid enabling both approaches for the same connection. Refer to the <a href=\"https:\/\/dbeaver.com\/docs\/dbeaver\/SSH-Configuration\/\">DBeaver SSH configuration documentation<\/a> for additional settings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Manage PostgreSQL with Server Explorer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Database administration is often part of a larger investigation. You might need to inspect application logs, check a Docker container, review a configuration file, and examine database records during the same session.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/getserverexplorer.app\/\">Server Explorer<\/a> is a desktop SSH management application for macOS and Windows with an integrated database workspace supporting PostgreSQL, MySQL, MariaDB, and SQLite.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your Linux server using your usual SSH credentials, then open the database workspace. Select or configure a PostgreSQL connection according to your deployment and provide the required database credentials.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm that you are working with the intended server and database before inspecting or modifying any records.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-dominant-color=\"161c1f\" data-has-transparency=\"true\" style=\"--dominant-color: #161c1f;\" loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1610\" src=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-scaled.webp\" alt=\"Remote PostgreSQL connection settings in Server Explorer.\" class=\"wp-image-779 has-transparency\" srcset=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-scaled.webp 2560w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-300x189.webp 300w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-1024x644.webp 1024w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-768x483.webp 768w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-1536x966.webp 1536w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.27-2048x1288.webp 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><figcaption class=\"wp-element-caption\">Configure a remote PostgreSQL database connection directly in Server Explorer<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once connected, use the database workspace to browse tables and inspect their contents alongside your other server administration tools.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-dominant-color=\"1c2227\" data-has-transparency=\"true\" style=\"--dominant-color: #1c2227;\" loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1610\" src=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-scaled.webp\" alt=\"Remote PostgreSQL database management with Server Explorer.\" class=\"wp-image-780 has-transparency\" srcset=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-scaled.webp 2560w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-300x189.webp 300w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-1024x644.webp 1024w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-768x483.webp 768w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-1536x966.webp 1536w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.44.37-2048x1288.webp 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><figcaption class=\"wp-element-caption\">Browse PostgreSQL tables and inspect records from Server Explorer&#8217;s integrated database workspace<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This approach is especially useful when you <a href=\"https:\/\/getserverexplorer.app\/index.php\/2026\/11\/09\/manage-multiple-linux-servers\/\">manage multiple Linux servers<\/a> and want to keep database operations in the context of the relevant machine. Available connection options depend on your deployment, application version, and permissions.<\/p>\n\n\n<div class=\"section-cta article-cta\" lang=\"en\">\n <svg class=\"cta-network\" viewBox=\"0 0 1000 320\" fill=\"none\" aria-hidden=\"true\" focusable=\"false\" preserveAspectRatio=\"xMidYMid slice\">\n <g class=\"network-routes\" stroke=\"currentColor\" stroke-width=\"1\">\n  <path d=\"M1000 40H820L740 120H640L570 190H420\"\/><path d=\"M1000 130H880L780 230H630L560 300H390\"\/>\n  <path d=\"M1000 280H840L760 200V80L680 0\"\/><path d=\"M930 0V75L850 155H710L630 235H520\"\/>\n  <path d=\"M530 0L610 80H710L790 0\"\/><path d=\"M1000 190H940L865 265V320\"\/>\n <\/g>\n <g class=\"network-signal\" stroke=\"currentColor\" stroke-width=\"2\" stroke-dasharray=\"32 720\">\n  <path d=\"M1000 40H820L740 120H640L570 190H420\"\/><path d=\"M1000 130H880L780 230H630L560 300H390\"\/>\n <\/g>\n <g class=\"network-nodes\" stroke=\"currentColor\" stroke-width=\"1.2\">\n  <rect x=\"728\" y=\"108\" width=\"24\" height=\"24\" rx=\"7\"\/><rect x=\"768\" y=\"218\" width=\"24\" height=\"24\" rx=\"7\"\/>\n  <rect x=\"838\" y=\"143\" width=\"24\" height=\"24\" rx=\"7\"\/><circle cx=\"610\" cy=\"80\" r=\"5\"\/><circle cx=\"630\" cy=\"235\" r=\"5\"\/><circle cx=\"865\" cy=\"265\" r=\"5\"\/>\n <\/g>\n <g fill=\"currentColor\"><circle cx=\"740\" cy=\"120\" r=\"3\"\/><circle cx=\"780\" cy=\"230\" r=\"3\"\/><circle cx=\"850\" cy=\"155\" r=\"3\"\/><\/g>\n<\/svg>\n <div class=\"section-cta-copy\">\n  <span class=\"cta-eyebrow\"><span class=\"cta-connection\" aria-hidden=\"true\"><\/span>Server Explorer<\/span>\n  <h3>Bring your servers into focus.<\/h3>\n  <p>A desktop app for macOS and Windows. Connect over SSH.<\/p> <\/div>\n <a class=\"button cta-button\" data-download-auto data-download-mac=\"https:\/\/apps.apple.com\/bj\/app\/server-files-explorer\/id6474502110?l=fr-FR&#038;mt=12\" data-download-windows=\"https:\/\/apps.microsoft.com\/detail\/9nrb68w7pjg8?gl=US&#038;hl=en-US\" href=\"https:\/\/getserverexplorer.app\/#download\">Download<span class=\"cta-arrow\" aria-hidden=\"true\">\u2197<\/span><\/a>\n<\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\">5. Access PostgreSQL running inside Docker<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Containerized PostgreSQL requires an additional check. The database may listen on port 5432 inside the container without exposing that port on the VPS itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the server, inspect the running containers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the database is already accessible on the VPS loopback interface, forward that host port using the SSH command shown earlier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a new Docker Compose deployment that requires host-based database access, a loopback-only port mapping can be configured under the database service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ports:\n  - \"127.0.0.1:5432:5432\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike a generic <code>5432:5432<\/code> mapping, this explicitly binds the published port to the IPv4 loopback interface. Check your Docker version, firewall configuration, and actual network exposure; older Docker versions have known limitations with localhost-published ports.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not recreate a production database container just to apply this change without checking persistent storage, backups, and downtime requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Server Explorer also supports database connections for compatible Docker deployments. Inspect the database container and use the database workspace where supported; the exact access method depends on your setup.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-dominant-color=\"161c1f\" data-has-transparency=\"true\" style=\"--dominant-color: #161c1f;\" loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1610\" src=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-scaled.webp\" alt=\"PostgreSQL Docker database management in Server Explorer.\" class=\"wp-image-781 has-transparency\" srcset=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-scaled.webp 2560w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-300x189.webp 300w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-1024x644.webp 1024w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-768x483.webp 768w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-1536x966.webp 1536w, https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/Capture-decran-2026-11-29-a-21.51.17-2048x1288.webp 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><figcaption class=\"wp-element-caption\">Access PostgreSQL databases running inside Docker containers with Server Explorer<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">6. Troubleshoot PostgreSQL SSH connection errors<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A successful SSH login does not necessarily mean PostgreSQL is reachable. Use the error message to narrow down the problem.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Error<\/th><th>What to check<\/th><\/tr><\/thead><tbody><tr><td>Connection refused<\/td><td>PostgreSQL listener, remote destination port, container mapping<\/td><\/tr><tr><td>Address already in use<\/td><td>Choose a different local forwarding port<\/td><\/tr><tr><td>Password authentication failed<\/td><td>Database username and password<\/td><\/tr><tr><td>No pg_hba.conf entry<\/td><td>Database authentication rules for the connection source<\/td><\/tr><tr><td>Administratively prohibited<\/td><td>SSH server forwarding restrictions<\/td><\/tr><tr><td>Connection timed out<\/td><td>SSH connectivity or reachability of the remote database host<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Run the SSH command again with <code>-v<\/code> for diagnostic output. For authentication failures, inspect PostgreSQL logs and its <code>pg_hba.conf<\/code> rules rather than disabling authentication. Remember that PostgreSQL sees the connection coming from the SSH server&#8217;s side of the tunnel, not directly from your laptop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Security best practices<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Keep the database port private whenever possible. Use SSH keys, verify server host keys, and assign dedicated database roles with only the privileges required for each task. Prefer read-only access for production investigations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not change <code>listen_addresses<\/code> to <code>*<\/code> or add broad <code>trust<\/code> rules simply to make remote access work. If your database is on another machine beyond the SSH server, consider PostgreSQL TLS as well: SSH encryption covers the tunnel to the SSH server, not necessarily the remaining network path.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final thoughts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Accessing PostgreSQL over SSH is a practical way to work with remote databases without opening their ports to the public internet. OpenSSH gives you direct control over forwarding, while DBeaver provides a dedicated graphical database workflow.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If database access is one of several tasks you perform on a VPS, Server Explorer brings database inspection together with files, terminals, logs, and Docker management. Choose the workflow that fits your deployment, and keep database permissions and network exposure as restrictive as possible.<\/p>\n\n\n<div class=\"section-cta article-cta\" lang=\"en\">\n <svg class=\"cta-network\" viewBox=\"0 0 1000 320\" fill=\"none\" aria-hidden=\"true\" focusable=\"false\" preserveAspectRatio=\"xMidYMid slice\">\n <g class=\"network-routes\" stroke=\"currentColor\" stroke-width=\"1\">\n  <path d=\"M1000 40H820L740 120H640L570 190H420\"\/><path d=\"M1000 130H880L780 230H630L560 300H390\"\/>\n  <path d=\"M1000 280H840L760 200V80L680 0\"\/><path d=\"M930 0V75L850 155H710L630 235H520\"\/>\n  <path d=\"M530 0L610 80H710L790 0\"\/><path d=\"M1000 190H940L865 265V320\"\/>\n <\/g>\n <g class=\"network-signal\" stroke=\"currentColor\" stroke-width=\"2\" stroke-dasharray=\"32 720\">\n  <path d=\"M1000 40H820L740 120H640L570 190H420\"\/><path d=\"M1000 130H880L780 230H630L560 300H390\"\/>\n <\/g>\n <g class=\"network-nodes\" stroke=\"currentColor\" stroke-width=\"1.2\">\n  <rect x=\"728\" y=\"108\" width=\"24\" height=\"24\" rx=\"7\"\/><rect x=\"768\" y=\"218\" width=\"24\" height=\"24\" rx=\"7\"\/>\n  <rect x=\"838\" y=\"143\" width=\"24\" height=\"24\" rx=\"7\"\/><circle cx=\"610\" cy=\"80\" r=\"5\"\/><circle cx=\"630\" cy=\"235\" r=\"5\"\/><circle cx=\"865\" cy=\"265\" r=\"5\"\/>\n <\/g>\n <g fill=\"currentColor\"><circle cx=\"740\" cy=\"120\" r=\"3\"\/><circle cx=\"780\" cy=\"230\" r=\"3\"\/><circle cx=\"850\" cy=\"155\" r=\"3\"\/><\/g>\n<\/svg>\n <div class=\"section-cta-copy\">\n  <span class=\"cta-eyebrow\"><span class=\"cta-connection\" aria-hidden=\"true\"><\/span>Server Explorer<\/span>\n  <h3>Bring your servers into focus.<\/h3>\n  <p>A desktop app for macOS and Windows. Connect over SSH.<\/p> <\/div>\n <a class=\"button cta-button\" data-download-auto data-download-mac=\"https:\/\/apps.apple.com\/bj\/app\/server-files-explorer\/id6474502110?l=fr-FR&#038;mt=12\" data-download-windows=\"https:\/\/apps.microsoft.com\/detail\/9nrb68w7pjg8?gl=US&#038;hl=en-US\" href=\"https:\/\/getserverexplorer.app\/#download\">Download<span class=\"cta-arrow\" aria-hidden=\"true\">\u2197<\/span><\/a>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Your application runs on a Linux VPS, and its PostgreSQL database is only accessible from the server. Now you need to inspect a table, investigate a bug, or verify a migration from your computer. Opening port 5432 to the internet might seem like the easiest solution. However, an SSH tunnel lets you connect to PostgreSQL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":782,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[228,230],"tags":[236,233,232],"class_list":["post-778","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-tutorials","tag-postgresql-gui-client","tag-postgresql-ssh-tunnel","tag-remote-postgresql-database"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v29.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Access a Remote PostgreSQL Database over SSH - Server Explorer<\/title>\n<meta name=\"description\" content=\"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Access a Remote PostgreSQL Database over SSH - Server Explorer\" \/>\n<meta property=\"og:description\" content=\"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/\" \/>\n<meta property=\"og:site_name\" content=\"Server Explorer\" \/>\n<meta property=\"article:published_time\" content=\"2026-12-03T20:52:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1672\" \/>\n\t<meta property=\"og:image:height\" content=\"941\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"darrellkidjo.dev\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@darrell_kidjo\" \/>\n<meta name=\"twitter:site\" content=\"@darrell_kidjo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"darrellkidjo.dev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/\"},\"author\":{\"name\":\"darrellkidjo.dev\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#\\\/schema\\\/person\\\/20f67c2affa11693453fec19477c9ec8\"},\"headline\":\"How to Access a Remote PostgreSQL Database over SSH\",\"datePublished\":\"2026-12-03T20:52:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/\"},\"wordCount\":1210,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp\",\"keywords\":[\"PostgreSQL GUI client\",\"PostgreSQL SSH tunnel\",\"remote PostgreSQL database\"],\"articleSection\":[\"Database\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/\",\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/\",\"name\":\"How to Access a Remote PostgreSQL Database over SSH - Server Explorer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp\",\"datePublished\":\"2026-12-03T20:52:09+00:00\",\"description\":\"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#primaryimage\",\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp\",\"contentUrl\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp\",\"width\":1672,\"height\":941},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/2026\\\/12\\\/03\\\/how-to-access-a-remote-postgresql-database-over-ssh\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/getserverexplorer.app\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Access a Remote PostgreSQL Database over SSH\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#website\",\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/\",\"name\":\"Server Explorer\",\"description\":\"Server Explorer SSH client - SFTP Explorer, VPS Security, terminal, Ai Integrated, Cron Management, Docker Manager for Linux servers on Mac and Windows\",\"publisher\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#organization\"},\"alternateName\":\"Server Files Explorer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/getserverexplorer.app\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#organization\",\"name\":\"Server Explorer\",\"alternateName\":\"Server Files Explorer\",\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/OIG.P8HQiZbb_YxAtGo_Pkmw-removebg-preview.png\",\"contentUrl\":\"https:\\\/\\\/getserverexplorer.app\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/OIG.P8HQiZbb_YxAtGo_Pkmw-removebg-preview.png\",\"width\":500,\"height\":500,\"caption\":\"Server Explorer\"},\"image\":{\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/darrell_kidjo\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/darrell-kidjo-ab49381a3\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/getserverexplorer.app\\\/#\\\/schema\\\/person\\\/20f67c2affa11693453fec19477c9ec8\",\"name\":\"darrellkidjo.dev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g\",\"caption\":\"darrellkidjo.dev\"},\"sameAs\":[\"https:\\\/\\\/getserverexplorer.app\"],\"url\":\"https:\\\/\\\/getserverexplorer.app\\\/index.php\\\/author\\\/darrellkidjo-dev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Access a Remote PostgreSQL Database over SSH - Server Explorer","description":"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/","og_locale":"en_US","og_type":"article","og_title":"How to Access a Remote PostgreSQL Database over SSH - Server Explorer","og_description":"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.","og_url":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/","og_site_name":"Server Explorer","article_published_time":"2026-12-03T20:52:09+00:00","og_image":[{"width":1672,"height":941,"url":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp","type":"image\/png"}],"author":"darrellkidjo.dev","twitter_card":"summary_large_image","twitter_creator":"@darrell_kidjo","twitter_site":"@darrell_kidjo","twitter_misc":{"Written by":"darrellkidjo.dev","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#article","isPartOf":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/"},"author":{"name":"darrellkidjo.dev","@id":"https:\/\/getserverexplorer.app\/#\/schema\/person\/20f67c2affa11693453fec19477c9ec8"},"headline":"How to Access a Remote PostgreSQL Database over SSH","datePublished":"2026-12-03T20:52:09+00:00","mainEntityOfPage":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/"},"wordCount":1210,"commentCount":0,"publisher":{"@id":"https:\/\/getserverexplorer.app\/#organization"},"image":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#primaryimage"},"thumbnailUrl":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp","keywords":["PostgreSQL GUI client","PostgreSQL SSH tunnel","remote PostgreSQL database"],"articleSection":["Database","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/","url":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/","name":"How to Access a Remote PostgreSQL Database over SSH - Server Explorer","isPartOf":{"@id":"https:\/\/getserverexplorer.app\/#website"},"primaryImageOfPage":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#primaryimage"},"image":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#primaryimage"},"thumbnailUrl":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp","datePublished":"2026-12-03T20:52:09+00:00","description":"Learn how to access a remote PostgreSQL database over SSH without exposing your database to the internet.","breadcrumb":{"@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#primaryimage","url":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp","contentUrl":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2026\/11\/PostgreSQL-Over-SSH_-Secure-Database-Access.webp","width":1672,"height":941},{"@type":"BreadcrumbList","@id":"https:\/\/getserverexplorer.app\/index.php\/2026\/12\/03\/how-to-access-a-remote-postgresql-database-over-ssh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/getserverexplorer.app\/"},{"@type":"ListItem","position":2,"name":"How to Access a Remote PostgreSQL Database over SSH"}]},{"@type":"WebSite","@id":"https:\/\/getserverexplorer.app\/#website","url":"https:\/\/getserverexplorer.app\/","name":"Server Explorer","description":"Server Explorer SSH client - SFTP Explorer, VPS Security, terminal, Ai Integrated, Cron Management, Docker Manager for Linux servers on Mac and Windows","publisher":{"@id":"https:\/\/getserverexplorer.app\/#organization"},"alternateName":"Server Files Explorer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/getserverexplorer.app\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/getserverexplorer.app\/#organization","name":"Server Explorer","alternateName":"Server Files Explorer","url":"https:\/\/getserverexplorer.app\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/getserverexplorer.app\/#\/schema\/logo\/image\/","url":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2024\/01\/OIG.P8HQiZbb_YxAtGo_Pkmw-removebg-preview.png","contentUrl":"https:\/\/getserverexplorer.app\/wp-content\/uploads\/2024\/01\/OIG.P8HQiZbb_YxAtGo_Pkmw-removebg-preview.png","width":500,"height":500,"caption":"Server Explorer"},"image":{"@id":"https:\/\/getserverexplorer.app\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/darrell_kidjo","https:\/\/www.linkedin.com\/in\/darrell-kidjo-ab49381a3\/"]},{"@type":"Person","@id":"https:\/\/getserverexplorer.app\/#\/schema\/person\/20f67c2affa11693453fec19477c9ec8","name":"darrellkidjo.dev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/475cdf09b61eef7d56e50d2142844c4b668e33b2dd5202b6d97932ea1441fc7a?s=96&d=mm&r=g","caption":"darrellkidjo.dev"},"sameAs":["https:\/\/getserverexplorer.app"],"url":"https:\/\/getserverexplorer.app\/index.php\/author\/darrellkidjo-dev\/"}]}},"_links":{"self":[{"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/posts\/778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/comments?post=778"}],"version-history":[{"count":1,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/posts\/778\/revisions"}],"predecessor-version":[{"id":783,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/posts\/778\/revisions\/783"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/media\/782"}],"wp:attachment":[{"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/media?parent=778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/categories?post=778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/getserverexplorer.app\/index.php\/wp-json\/wp\/v2\/tags?post=778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}