---
url: https://docs.zenavo.app/networking/private
---

# Private Networking

Services in the same project reach each other by private hostname:

```
<hostname>.zenavo.internal
```

For example, an API connects to `postgresql.zenavo.internal:5432`. A new service's hostname comes from its name (`My API` → `my-api`, a second PostgreSQL → `postgresql-2`); it is shown on the service's **Networking** tab under **Private**, where the pencil button changes it. Traffic stays inside the server; projects cannot reach each other's services.

## Isolation between projects

A project's services accept connections only from the same project and from the server's router, which brings in your [domains](https://docs.zenavo.app/networking/domains)' traffic. Another project on the same server cannot connect to them, by private name, cluster name or address, except on ports you [publish](https://docs.zenavo.app/networking/tcp-udp), which are open to everyone.

From inside a project, services reach the internet, the server's domains and other projects' published ports. They cannot reach the server's own ports besides HTTP(S) and published ones (SSH, Kubernetes, the Zenavo agent), nor the cloud provider's metadata service (`169.254.169.254`).

Servers set up before this isolation existed need their setup run once more (the server's **Settings** → **Run setup**); it does not stop your projects. Until then, deployments to such a server go on without isolation and say so in the deploy log. Once setup has run, the server's existing projects are isolated within a minute or two, without redeploying them.

## Name resolution

Private hosts are real DNS names on the server's resolver, so they work everywhere: the system resolver, `dig` and `nslookup`, and programs that query DNS themselves, such as nginx's `resolver` with a variable `proxy_pass`, or Go and Node clients with their own resolver. Point nginx at the nameserver from the container's `/etc/resolv.conf`:

```nginx
resolver 10.43.0.10 valid=10s;   # the nameserver line of /etc/resolv.conf
set $api api.zenavo.internal;
location / { proxy_pass http://$api:8080; }
```

A name only ever resolves to a service in the asking service's own project: `api.zenavo.internal` means a different service in each project, and a name no service in your project has returns no address. The [service ID](#service-ids) also works as a name (`svc-k3j9x2ab7m4q.zenavo.internal`). Every container's `/etc/hosts` also lists the project's private hosts, as a fallback.

The answer is a CNAME to the service's cluster name (`api.<project namespace>.svc.cluster.local`) followed by its address; configure the `zenavo.internal` name, since the cluster name is an internal detail that may change.

On a newly connected server, private DNS starts working a minute or two after the first deployment; `/etc/hosts` covers that window.

## Changing a hostname

A new hostname applies on the service's next deploy, and the old one stops resolving then. Variables that use `${CONTAINER_HOSTNAME}` (as the [database](https://docs.zenavo.app/deploy/databases) services' shared variables do) follow the change; anything that has the old address typed in, such as a connection string you wrote yourself, must be updated.

## Service IDs

Every service also has a permanent, random ID such as `svc-k3j9x2ab7m4q`, shown under its name and in its **Settings**. Volumes, logs and [API](https://docs.zenavo.app/api/overview) routes use it, so renaming a service or changing its hostname moves no data.

A removed service's ID is never given to another service: its volumes stay for 7 days after its removal ([Deleting a service](https://docs.zenavo.app/operations/volumes#deleting-a-service)), and its logs and build history keep the ID after that.

Services created before hostnames existed have an ID made from their name (`postgresql`), which is also their hostname until you choose another.

## Ports

**Expose Port** under **Private** adds a port the service listens on. Each port has:

- a **name**, such as `web`, used in [built-in variables](https://docs.zenavo.app/deploy/environment-variables#built-in-variables) like `WEB_PORT`;
- a **number**, the port inside the container;
- a **type**: HTTP (can get a domain), TCP or UDP (can be [published](https://docs.zenavo.app/networking/tcp-udp)).

Changes to ports apply right away: Zenavo saves them and redeploys the service. While another deployment runs, the redeploy [waits for it](https://docs.zenavo.app/deploy/how-deploys-work#deploy-queue). A domain change alone is routed without a redeploy ([Domains & HTTPS](https://docs.zenavo.app/networking/domains#when-a-deploy-is-needed)).
