# Streamlit app on Foundry: NameResolutionError when calling Foundry API despite network policy configuration

**URL:** <https://community.palantir.com/t/streamlit-app-on-foundry-nameresolutionerror-when-calling-foundry-api-despite-network-policy-configuration/5283>\
**Category:** Ask the Community\
**Tags:** workshop, foundry-rules\
**Created:** [October 20, 2025, 11:09am UTC](https://community.palantir.com/t/streamlit-app-on-foundry-nameresolutionerror-when-calling-foundry-api-despite-network-policy-configuration/5283 "2025-10-20T11:09:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bee8524a2ef55771cd55](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/bee8524a2ef55771cd55/32/5279_2.png) [@bee8524a2ef55771cd55](https://community.palantir.com/u/bee8524a2ef55771cd55)\
**Post date:** [October 20, 2025, 11:09am UTC](https://community.palantir.com/t/streamlit-app-on-foundry-nameresolutionerror-when-calling-foundry-api-despite-network-policy-configuration/5283/1 "2025-10-20T11:09:23Z")

</div>

Hi everyone,

I’m running a Streamlit application inside Foundry Workshop, and the app makes a call to a Foundry API endpoint (for example, to retrieve ontology objects or trigger functions).

However, when the call executes, I get the following error:

```auto
NameResolutionError(": Failed to resolve 'foundry_host' ([Errno -2] Name or service not known)")

```

Here’s what I’ve already done:

- Added the Foundry host URL to the Workspace’s network policy

- Included the same Foundry host URL in the Streamlit app’s egress network policy

Despite that, the application still cannot resolve the host.

My questions are:

1. Is there another recommended way to **r** eference Ontologies or Foundry APIs from within a Streamlit app _without_ using the explicit Foundry host URL?

2. Is there a built-in way to authenticate or generate a token (for example using the Streamlit runtime or Foundry environment context) instead of manually calling the OAuth/token endpoint?

3. Am I missing any configuration that enables internal API calls from Foundry-hosted Streamlit apps to Foundry itself?

Any advice, best practices, or examples from others who have integrated Foundry APIs in Streamlit would be greatly appreciated.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [October 15, 2026, 11:10am UTC](https://community.palantir.com/t/streamlit-app-on-foundry-nameresolutionerror-when-calling-foundry-api-despite-network-policy-configuration/5283/2 "2026-10-15T11:10:11Z")

</div>

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.
