> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemreference/functions/environment/hostname.md).

# Hostname

{% hint style="info" %}
The **`Hostname()`** function returns the domain name of the active portal of your published WEM project.

For more information about the domain name visit <https://en.wikipedia.org/wiki/Domain_name>.

This function can be used to create links to (specific pages of) your application. For example a link in a reset password or create account e-mail (see syntax for an example). By using the hostname function you ensure that the generated link always points to the right portal in the right environment.

**Portals/applications can have multiple hostnames, and this function will return the Hostname which was used at the first incoming external Request (from a user session).**

This function is SQL compatible - as it is a constant value within a session. For more information about SQL compatibility, see our [documentation](/platform/wemreference/sql-compatibility.md).
{% endhint %}

{% hint style="warning" %}
When the flow is called within a **non-user context**, the result can be an internal value.

For example in WEM-Native Scheduled Tasks on Kubernetes, if you are using the Hostname() function and you expect it to return the external portal hostname - you will be surprised that it returns "`applicationservice`" because of the internal context in which Scheduled Tasks on Kubernetes run.&#x20;

Scheduled Tasks do NOT run in the context of the external hostname.

So - if you have a Scheduled Task in which you want to set a value with the hostname of your application, you need to use a specific value and cannot use the Hostname() function.
{% endhint %}

{% hint style="success" %}
Returns a text that contains the hostname of the portal in its particular runtime environment when used.&#x20;
{% endhint %}

### Syntax

<details>

<summary><code>Hostname()</code></summary>

`Hostname()`\
*=> portalname.staging.wem.io (on staging runtime)*\
*=> portalname.live.wem.io (on live runtime)*\
*=> yourcustomhostname.extension (on live runtime)*\
*=> applicationservice (when used in WEM Scheduled Task on Kubernetes Runtime)*

*`"https://" + Hostname() + "/create-account"`*\
*=> <https://portalname.staging.wem.io/create-account> (on staging runtime)*\
*=> <https://portalname.live.wem.io/create-account> (on live runtime)*\
*=> <https://applicationservice/create-account> (when used in WEM Scheduled Task on Kubernetes Runtime)*

</details>


---

# 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.wem.io/platform/wemreference/functions/environment/hostname.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.
