# Tcp connect error: Network is unreachable

**URL:** <https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041>\
**Category:** Developers\
**Created:** [March 1, 2024, 7:55pm UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041 "2024-03-01T19:55:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [March 1, 2024, 7:55pm UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/1 "2024-03-01T19:55:43Z")

</div>

I’m helping someone out at a hackathon and they have local http requests working but not in production, they get this error: `tcp connect error: Network is unreachable`.

Any insights?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [March 1, 2024, 8:15pm UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/2 "2024-03-01T20:15:48Z")

</div>

Here is the code:

```typescript

import {
    Server,
    serialize
} from 'azle';
import express from 'express';

export default Server(() => {
    const app = express();

    app.use(express.json());

    async function getAccounts(access_token: string) {
        const authorization = 'Bearer ' + access_token;

        const response = await fetch(`icp://aaaaa-aa/http_request`, {
            body: serialize({
                args: [
                    {
                        url: https://buildhathon-sandbox.biapi.pro/2.0/users/me/accounts,
                        max_response_bytes: [],
                        method: {
                            get: null
                        },
                        headers: [
                            {name: 'Authorization', value: authorization},
                            {name: 'Content-Type', value: 'application/json'}
                        ],
                        body: [],
                        transform: []
                    }
                ],
                cycles: 30000000000
            })
        });

        return await response.json();
    }

    app.post('/web2/accounts', async (req, res) => {
        const { access_token } = req.body;

        try {
            const balanceData = await getAccounts(access_token);
            const serializedData = JSON.parse(Buffer.from(balanceData.body).toString('utf-8'));
            res.json(serializedData);
        } catch (error: any) {
            const errorTxt = 'Error fetching accounts: ' + error.message;
            res.status(500).json({ error: errorTxt });
        }
    });

    app.use(express.static('/dist'));

    return app.listen();
});

```

---

<div class="post-metadata">

**Author:** ![bjoerntm](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bjoerntm/32/32346_2.png) [@bjoerntm](https://forum.dfinity.org/u/bjoerntm)\
**Post date:** [March 1, 2024, 9:37pm UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/3 "2024-03-01T21:37:13Z")

</div>

Maybe attempt to connect to IPv4 in a setting where only IPv6 is supported?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [March 1, 2024, 10:25pm UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/4 "2024-03-01T22:25:45Z")

</div>

Yes seems so…thank you

---

<div class="post-metadata">

**Author:** ![bruno353](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bruno353/32/15709_2.png) [@bruno353](https://forum.dfinity.org/u/bruno353)\
**Post date:** [August 23, 2024, 1:01am UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/5 "2024-08-23T01:01:00Z")

</div>

So how did you resolve this? If the server does not allow IPv6 connections we cannot make canister http calls to it?

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [August 23, 2024, 1:05am UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/6 "2024-08-23T01:05:03Z")

</div>

Yes you cannot make canister calls directly to the server in that case. A workaround can be to include a proxy IPv6 server in the middle, so your canister will make calls to this proxy and than proxy will handle calls to your primary server.

---

<div class="post-metadata">

**Author:** ![bruno353](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bruno353/32/15709_2.png) [@bruno353](https://forum.dfinity.org/u/bruno353)\
**Post date:** [August 23, 2024, 1:21am UTC](https://forum.dfinity.org/t/tcp-connect-error-network-is-unreachable/28041/7 "2024-08-23T01:21:12Z")

</div>

got it, Im thinking in using Cloudfront to receive the calls and then forward it to my backend (that only accepts IPv4), let me know if you have a better solution!
