17 days ago
Why do I frequently get this error when trying to make a request to my API using React Native/Expo Go?
Login Request
LOG → Request (1): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Tentativa 1 falhou. Tentando novamente...
LOG → Request (2): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Tentativa 2 falhou. Tentando novamente...
LOG → Request (3): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Erro no fetch: [TypeError: Network request failed]
Earlier, I only got [TypeError: Network request failed].
In the same app, I tested endpoints from another API (Java) hosted on Railway, and it responded normally to all requests.
In Postman and other languages, the requests do not fail.
To wrap up, I deployed the same API to another service (Render) and it worked without issues. That’s why I think something is wrong.
6 Replies
17 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 17 days ago
17 days ago
Looks like health check is failing after deployment.
Can you check your health check config in the service.
If there is a endpoint configured in railway panel, you need that endpoint in service.
If you do not have the endpoint implemented, remove the health check path from panel, untill you get it up and running.
Attachments
17 days ago
this is a known combo, react native on android + railway. two likely causes:
check if App Sleeping is on - service settings → deploy → app sleeping (serverless). if your api sleeps after idle, the first requests after a pause fail while it wakes up, and your 3 quick retries all land during the wakeup. postman works because by then its awake, and render doesnt sleep. turn it off and test again.
if sleeping is already off, its stale keep-alive connections. androids okhttp reuses open sockets, but railways edge proxy closes idle ones sooner than renders does, so the reused socket is dead and fetch throws "network request failed". quick test: add Connection: close to your fetch headers - if the errors stop, thats it. then either keep that header or add retry with a small delay instead of instant retries.
btw your retries firing instantly back to back is why all 3 fail, put like 2-3s between them either way
azashi
Looks like health check is failing after deployment. Can you check your health check config in the service. If there is a endpoint configured in railway panel, you need that endpoint in service. If you do not have the endpoint implemented, remove the health check path from panel, untill you get it up and running. 
17 days ago
The health check is fine now. However, the issues with the requests persist.
Request (1): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/register
LOG Tentativa 1 falhou. Tentando novamente...
LOG → Request (2): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/register
LOG Tentativa 2 falhou. Tentando novamente...
LOG → Request (3): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/register
LOG Erro no fetch: [TypeError: Network request failed]
LOG Login Request
LOG → Request (1): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Tentativa 1 falhou. Tentando novamente...
LOG → Request (2): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Tentativa 2 falhou. Tentando novamente...
LOG → Request (3): POST https://api-delivroo-express-node-production.up.railway.app/api/riders/login
LOG Erro no fetch: [TypeError: Network request failed]
manuproject
this is a known combo, react native on android + railway. two likely causes: check if App Sleeping is on - service settings → deploy → app sleeping (serverless). if your api sleeps after idle, the first requests after a pause fail while it wakes up, and your 3 quick retries all land during the wakeup. postman works because by then its awake, and render doesnt sleep. turn it off and test again. if sleeping is already off, its stale keep-alive connections. androids okhttp reuses open sockets, but railways edge proxy closes idle ones sooner than renders does, so the reused socket is dead and fetch throws "network request failed". quick test: add Connection: close to your fetch headers - if the errors stop, thats it. then either keep that header or add retry with a small delay instead of instant retries. btw your retries firing instantly back to back is why all 3 fail, put like 2-3s between them either way
12 days ago
I've been dealing with the same problem for months... If you find a solution, please share it.
a day ago
I have the same problem. All my Expo apps are failing. The only solution when it starts acting up is to change my API region; that fixes it for a few days. 🤬🤬
5 hours ago
I found the solution: using another service like Render, where I don't have this kind of problem.

