> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/guides-and-examples/advanced-guides/serve-traffic-on-multiple-ports.md).

# Serve traffic on multiple ports

How to set up a service that accepts traffic on two different ports

Release currently only supports serving HTTP traffic from the first port defined by your service. In the following example, the service RCON listens on port 4326 for the web user interface, and port 4327 is used for websocket traffic from the web application.

```yaml
hostnames:
  - rcon: rcon-${env_id}-${domain}

services:
- name: rcon
  image: itzg/rcon
  ports:
  - type: node_port
    target_port: '4326'
    port: '4326'
  - type: node_port
    target_port: '4327'
    port: '4327'
```

By default, Release will ignore the second port and route all HTTP traffic to port 4326. You can work around this limitation by duplicating the service in Release.

```yaml
hostnames:
  - rcon: rcon-${env_id}-${domain}
  - websocket: websocket-${env_id}-${domain}

services:
- name: rcon
  image: itzg/rcon
  ports:
  - type: node_port
    target_port: '4326'
    port: '4326'

- name: websocket
  image: itzg/rcon
  ports:
  - type: node_port
    target_port: '4327'
    port: '4327'
```

This workaround requires your application container to be stateless, and you will need to configure your environment variables to let the web UI know which URL to talk to for websocket traffic. See [Environment Variables](/reference-documentation/environment-settings/environment-specific-environment-variables.md) for more information about environment-specific environment variables.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/guides-and-examples/advanced-guides/serve-traffic-on-multiple-ports.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
