# Cannot fetch from preact node docker

**URL:** <https://forums.docker.com/t/cannot-fetch-from-preact-node-docker/145297>\
**Category:** General\
**Tags:** docker, networking\
**Created:** [December 4, 2024, 12:55pm UTC](https://forums.docker.com/t/cannot-fetch-from-preact-node-docker/145297 "2024-12-04T12:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flbe](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/flbe/32/50708_2.png) [@flbe](https://forums.docker.com/u/flbe)\
**Post date:** [December 4, 2024, 12:55pm UTC](https://forums.docker.com/t/cannot-fetch-from-preact-node-docker/145297/1 "2024-12-04T12:55:16Z")

</div>

I am running preact in a Node Docker, and a rest-api in a phpapache docker.

- docker run --network vumc-network -p 80:80 --name phpapache phpapache
- docker run -p 4200:4200 --network vumc-network --name node node  
When i log in the node docker I can execute:

```auto
const http = require('http');

http.get('http://phpapache/nl/menu', (res) => {
  let data = '';
  res.on('data', (chunk) => {
    data += chunk;
  });
  res.on('end', () => {
    console.log(data);
  });
}).on('error', (error) => {
  console.error(error);
});

```

which correctly returns a json.  
But in de react-app is a function that does something similar:

```auto
fetch('http://phpapache/nl/menu')
      .then(res => res.json())
      .catch(error => {
        console.error(
          "There was a problem loading the database from DatabasesNav",
          error
        );
      });

```

which fails with an error: `TypeError: Failed to fetch`

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/bluepuma77/32/32688_2.png) [@bluepuma77](https://forums.docker.com/u/bluepuma77)\
**Post date:** [December 4, 2024, 2:48pm UTC](https://forums.docker.com/t/cannot-fetch-from-preact-node-docker/145297/2 "2024-12-04T14:48:26Z")

</div>

The react app usually runs in a browser and the browser is not connected to the Docker network and can not lookup the target service IP by name.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/docker/original/3X/6/9/69c4b276d1979e4e35a2f0338bac246a4de21daf.png) [@system](https://forums.docker.com/u/system)\
**Post date:** [December 14, 2024, 2:49pm UTC](https://forums.docker.com/t/cannot-fetch-from-preact-node-docker/145297/3 "2024-12-14T14:49:07Z")

</div>

Closed on December 14, 2024, 2:49pm UTC

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