[Insights](/insights/) / [Core Engineering Intelligence](/insights/core_engineering_intelligence/)

# Forward a remote port to your computer with SSH

Use ssh -L to open a database, admin panel or debug server that runs on a remote server on your own localhost, without opening it to the internet.

![Ivan Borshchov](https://static.devforth.io/adminusers/avatars/2026/48db9847-d461-40cd-b344-f2bd7b0d98ca-avatar_ivan@devforth.io_f4ce9df9-8363-4314-9345-28753c76a386.jpeg)

Ivan Borshchov

CEO & System Architect @ DevForth

Dec 3, 2026

![Forward a remote port to your computer with SSH](https://static.devforth.io/posts/logo-svg/2026/62b2a6d3-714d-471d-864e-c48d51d84d77-logo-preview-new.svg)

![Forward a remote port to your computer with SSH](https://static.devforth.io/posts/logo-svg/2026/62b2a6d3-714d-471d-864e-c48d51d84d77-logo-preview-new.svg)

Imagine a server with a door that only opens from the inside. Your database, admin panel or debug server is listening on a port behind it, and that port is closed to the internet. Good! Keep it closed.

SSH can dig a private tunnel to that door. You knock on the one door that is already open (SSH, port 22), and SSH carries your traffic through it.

```bash
ssh -N -L 8080:localhost:80 user@server_ip
```

Now open `http://localhost:8080` on your computer, and you are talking to port 80 _on the server_.

How to read `-L 8080:localhost:80`:

-   `8080` is the port on your computer.
-   `localhost:80` is the destination as the _server_ sees it, so `localhost` here means the server itself.
-   `-N` means "only keep the tunnel, don't open a shell". Press Ctrl+C to close it.

Two everyday uses:

-   Open a remote Postgres in your local database tool: `ssh -N -L 5433:localhost:5432 user@server_ip`, then connect to `localhost:5433`.
-   Reach a service that only listens on the server's private network: `-L 9000:10.0.0.5:9000`.

Things that trip people up:

-   If the local port is already taken, SSH will complain. Pick another one.
-   The tunnel only lasts as long as the SSH connection. Close the terminal and it's gone.
-   By default the tunnel listens only on your own machine, which is what you want. Other people on your Wi-Fi can't use it.

There is also the opposite direction, `-R`, which makes a port on your computer reachable from the server. Use it rarely and carefully.

In short: keep private ports closed, and use `ssh -L` to borrow them for yourself when you need them.

## Get your project quote

Free result within 48-72 hours

[

Get a quote

](/estimation-request/)[

Talk to our engineers

](https://talk.devforth.io/book/30-minute-meeting)

[

Back to insights

](/insights/)

[](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdevforth.io%2Finsights%2Fforward-a-remote-port-to-your-computer-with-ssh%2F)[](https://bsky.app/intent/compose?text=Forward%20a%20remote%20port%20to%20your%20computer%20with%20SSH%0A%0Ahttps%3A%2F%2Fdevforth.io%2Finsights%2Fforward-a-remote-port-to-your-computer-with-ssh%2F)[](https://x.com/intent/tweet?text=Forward%20a%20remote%20port%20to%20your%20computer%20with%20SSH%20by%20%40ivanborshchov%0A%0Ahttps%3A%2F%2Fdevforth.io%2Finsights%2Fforward-a-remote-port-to-your-computer-with-ssh%2F)

## Related insights

[

![Blocking vs asynchronous code, explained simply](https://static.devforth.io/posts/logo-svg/2026/1c717208-1a6c-497e-8676-3f879a925104-logo-preview-new.svg)

Core Engineering Intelligence Dec 3, 2026

## Blocking vs asynchronous code, explained simply

Blocking code stands and waits, async code works on something else in the meantime. Why that matters, and why neither one fixes a slow query.

](/insights/blocking-vs-asynchronous-code-explained-simply/)[

![Install PostgreSQL and create a database and user from the command line](https://static.devforth.io/posts/logo-svg/2026/4289b5ee-f719-4e22-8f1d-519f5fa1fa11-logo-preview-new.svg)

Core Engineering Intelligence Dec 3, 2026

## Install PostgreSQL and create a database and user from the command line

Install PostgreSQL on Ubuntu or WSL, then create a database owned by its own user in two SQL commands, and connect with one URL.

](/insights/install-postgresql-and-create-a-database-and-user-from-the-command-line/)[

![How to create an AWS account and keep it safe](https://static.devforth.io/posts/logo-svg/2026/9846537f-161d-4fbc-b845-786ab85ed79c-logo-preview-new.svg)

Core Engineering Intelligence Dec 3, 2026

## How to create an AWS account and keep it safe

Create an AWS account the safe way. Protect the root user with MFA, set a budget alert and use a separate short-lived login for daily work.

](/insights/how-to-create-an-aws-account-and-keep-it-safe/)
