How to resolve this error `Couldn't connect to compute node` & `Connection terminated unexpectedly`
Unanswered
.oxyzen posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/430616499674284033/f437c6f7f32742a873a9c0235d034217.webp?size=256)
.oxyzenOP
Hi, I hope you guys are doing well. I've been working with Vercel Postgres and encountered this error. Can anyone help me with this?
![Image](https://cdn.discordapp.com/attachments/1127272427773235200/1127272428016513034/Screenshot_2023-07-08_221559.png)
7 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Greater Flamingo
Hi @.oxyzen were you able to get this fixed? I'm having the same problem. It seems to come from Neon after a cold start
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Gazami crab
I also need help with this, and that is correct it seems to only happen on cold starts. I don't think this has to do with hot module reload on local env, its also happening deployed in vercel
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Gazami crab
From neon error docs.
![Image](https://cdn.discordapp.com/attachments/1127272427773235200/1128420603007869090/image.png)
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Greater Flamingo
@Gazami crab I managed to find a not very pretty workaround basically by doing retries 1s apart each other until it succeeds or it reaches the maximum retry. I've noticed that it only takes a couple of secs max to warm up the db so this works
Here's a snippet:
Here's a snippet:
const retryQuery = async (
retries = 3
): Promise<DailyBenchmark[]> => {
try {
return await query();
} catch (err) {
if (retries === 0) throw err;
await sleep(1000);
return await retryQuery(retries - 1);
}
};
If you find something better, please share it 🙂 I'll be also looking for a better solution. This sounds like an issue with Vercel and Neon though but I may be wrong
![Avatar](https://cdn.discordapp.com/avatars/430616499674284033/f437c6f7f32742a873a9c0235d034217.webp?size=256)
.oxyzenOP
I don't know if this count as a fix but I'm running the local dev server with
--turbo
flag. This works for me and didn't throw any error till now.![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Greater Flamingo
It should be fixed guys 🙂
![Image](https://cdn.discordapp.com/attachments/1127272427773235200/1129025872863711342/image.png)