Connect to a database from outside

Turn on public networking to reach a Hangar database from your laptop, a BI tool or another cloud through its own TCP proxy address.

Updated

A database on Hangar is private by default: only services in the same project can reach it, over the private network. When you need to reach it from outside, from your machine, a BI tool or a job running in another cloud, turn on public networking.

Public networking is available for PostgreSQL, MySQL, MariaDB, MongoDB and Redis.

Turn it on

Open the database and find Public networking next to its credentials. Switch it on. Hangar assigns a port and shows:

  • the host, a name for the database's region;
  • the port, picked for you;
  • a connection URL with the credentials, ready to paste into psql, a GUI client or a connection string.

There is nothing to configure, and the database's own settings do not change. Traffic goes through a small TCP proxy that Hangar runs next to it and forwards to the database over the private network.

Switch it off and the address stops answering. Switching it on again assigns a new port.

Your apps do not need it

Services in the same project should keep using the internal connection URL. It never leaves the private network, it is faster, and traffic between your services is not billed as egress. See Databases.

Keep it safe

A public address can be reached by anyone on the internet who knows it, so the database password is what protects it.

  • Turn public networking on only while you need it, or only for databases that must be reached from outside.
  • Do not paste the connection URL into places others can read, such as public repositories or shared chats.
  • If the credentials may have leaked, switch public networking off right away, then change the password and update the apps that use it.

Frequently asked questions

Can I connect to my Hangar database with psql, TablePlus or DBeaver?
Yes. Turn on public networking in the database's connection settings. Hangar gives the database a public host and port through a TCP proxy, and shows a connection URL you can paste into any client.
Do my apps on Hangar need public networking to reach the database?
No. Services in the same project reach the database over the private network with its internal connection URL. Public networking is only for clients outside Hangar.

Deploy your app on Hangar

Connect a repository and it is live in minutes.

Start deploying