> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/connectivity/load-balancer/how-tos/create-a-tcp-load-balancer.md).

# Create a TCP load balancer

It is possible to create a load balancer for almost any kind of TCP service.

***

## Create a TCP load balancer using the control panel

It is also possible to load balance TCP traffic that is not HTTP, such as PostgreSQL servers.

To set up a load balancer for TCP, create a new listener and select *tcp* under *Mode*. Enter the TCP port the listener should listen on. Then, add the targets and their TCP ports.

In the example below, we use PostgreSQL servers behind the load balancer.

<figure><img src="https://3379166260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlMZhhdQNcWOpX5Bj48GK%2Fuploads%2FpVrxKbsq3hShbSKA3t8o%2Ftcp-postgres-lb.png?alt=media&amp;token=abfdd682-3aeb-4d60-b475-ee58bff4a7a6" alt=""><figcaption></figcaption></figure>

## Create a TCP load balancer using the API

1. Use the [loadbalancer/create endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalancercreate) in the API to create a load balancer.&#x20;
2. To add a listener to the load balancer, use the [loadbalancer/addfrontend endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddfrontend).
3. To add a target (server) to the load balancer, use the [loadbalancer/addbackend endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddbackend).
4. To add a certificate to the listener for SSL traffic, use the [loadbalancer/addcertificate endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddcertificate).

Additional load balancer endpoints are available in the [loadbalancer module](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalancer-module).
