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.