"Network Request Failed" for all POST APIs
Anonymous
HOBBYOP

2 months ago

Hi there,

Backend: Django hosted on Railway

Frontend: React native based android app using fetch

Issue? On all the POST APIs, I'm getting "Network Request Failed"

I understand the error is vague, so I did some debugging on my side..

  • No frontend code was pushed recently.
  • No backend code was pushed.

I have been facing it for the last 1-2 weeks.

In my debugging, nothing from the code side seems like an issue.. The same API is working fine from Postman.

Even in my logs.. I can see the backend is returning 200 OK, but the frontend shows Network Request Failed.

I've also tried adding Connection: Close to my API Headers, and surprisingly it works half the time.

Moreover, my GET requests are working just fine.. its just my POST APIs which are failing. And it's a big issue, since users can't even create their profile.

I have also tried using the Railway-based host.. .....up.railway.app, and the result is same which means issue is not from Cloudflare side.

Solved$10 Bounty

19 Replies

Railway
BOT

2 months ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • about 2 months ago


2 months ago

Does your POST requests appear in the Network Logs?


mayori

Does your POST requests appear in the Network Logs?

Anonymous
HOBBYOP

2 months ago

Yes, they do. They are responding with 200 OK, and I am saving data correctly in the database. So, in my opinion, the backend is working fine.


Yes, they do. They are responding with `200 OK`, and I am saving data correctly in the database. So, in my opinion, the backend is working fine.

manuproject
FREE

2 months ago

basically what re u using the fetch for have you already build the apk

try to check if ur frontend if u set up any api or using context share here how the fetch request is


Yes, they do. They are responding with `200 OK`, and I am saving data correctly in the database. So, in my opinion, the backend is working fine.

manuproject
FREE

2 months ago

the problem is not the backend the problem is in ur react native


manuproject

basically what re u using the fetch for have you already build the apk try to check if ur frontend if u set up any api or using context share here how the fetch request is

Anonymous
HOBBYOP

2 months ago

Yes, the APK is already built and has been live for months without any issue.

I actually debugged the whole APK - nothing was changed in the last 2 weeks.. since the issue started appearing.. I also checked the entire logs on my APK; except for "Network request failed" I see nothing. No crashes. No errors. Just "Network request failed"


manuproject
FREE

2 months ago

did u debug using the web version of react native or how cos with that u can really find the exact error

by using the chrome dev tools


Yes, the APK is already built and has been live for months without any issue. I actually debugged the whole APK - nothing was changed in the last 2 weeks.. since the issue started appearing.. I also checked the entire logs on my APK; except for "Network request failed" I see nothing. No crashes. No errors. Just "Network request failed"

manuproject
FREE

2 months ago

or tell me how you debug let me understand very well


manuproject

or tell me how you debug let me understand very well

Anonymous
HOBBYOP

2 months ago

It's not supported on the browser because of certain libraries I use.

I did LOGCAT over the traces; I only see this

I ReactNativeJS: 'FULL ERROR:', '{"message":"Network request failed"}'

That too is just the console I am doing in my local.

I also did Connection: Close forcing the APK to terminate the network, which does help. The first request fails.. but then since the connection is terminated.. my second API is a success. But this is, of course, not a sustainable solution, and that's a reason I'm doubting the infra level instead of just the frontend code. (Frontend Infra can also be an issue - how services are interacting)


It's not supported on the browser because of certain libraries I use. I did LOGCAT over the traces; I only see this `I ReactNativeJS: 'FULL ERROR:', '{"message":"Network request failed"}'` That too is just the console I am doing in my local. I also did `Connection: Close` forcing the APK to terminate the network, which does help. The first request fails.. but then since the connection is terminated.. my second API is a success. But this is, of course, not a sustainable solution, and that's a reason I'm doubting the infra level instead of just the frontend code. (Frontend Infra can also be an issue - how services are interacting)

manuproject
FREE

2 months ago

re u using expo with react native??


Anonymous
HOBBYOP

2 months ago

It's marked as resolved, which isn't the case, unfortunately. Is there any way we can ping/open it again?


Anonymous
HOBBYOP

2 months ago

Thanks for a detailed response.

Strangely, I only see this in logs, after doing the changes as you posted.. and I'm still getting "Network Request Failed"

08-09 20:52:21.471 14471 15046 D NET : POST proto=h2

08-09 20:52:32.559 14471 15046 D NET : POST proto=h2

08-09 20:52:50.780 17090 17467 D NET : POST proto=http/1.1

08-09 20:52:51.389 17090 17468 D NET : POST proto=h2

08-09 20:52:51.391 17090 17469 D NET : GET proto=h2

08-09 20:52:51.458 17090 17467 D NET : GET proto=h2

08-09 20:52:52.772 17090 17467 D NET : GET proto=h2

08-09 20:52:52.774 17090 17468 D NET : GET proto=h2

08-09 20:52:52.785 17090 17469 D NET : GET proto=h2

08-09 20:53:16.051 17090 17468 D NET : GET proto=h2

08-09 20:53:24.604 17090 17468 D NET : POST proto=h2

08-09 20:53:27.186 17090 17468 D NET : POST proto=h2

08-09 20:53:28.335 17090 17468 D NET : POST proto=h2


Anonymous
HOBBYOP

2 months ago

I still have to test forcing the HTTP.. I will do in a while and update.

POST API is pretty simple: a simple JSON. The one I'm testing on has <10ms latency.,


Anonymous
HOBBYOP

2 months ago

Hey, so I tested all three cases, and they all worked perfectly!

Now my doubt is about the HTTP/2's connection pool in some way. Possibly the connection ended, but the App is not aware of it somehow. Is that the reason using Connection: Close was working? Forcing the app to terminate the port and build a fresh one for the next request?


Anonymous
HOBBYOP

2 months ago

Hmm, fair. But aren't we treating the symptoms instead of figuring/fixing the root cause?

For now, since the Backend is working fine and receiving the API, the profile does get created; my user sees "Network Request Failed", they close the app, and open it again - which is a very high friction point and a significant drop-off. So it might work as a temporary fix. But what's the underlying main issue? I'm sure this isn't the first or the last issue..


Anonymous
HOBBYOP

2 months ago

I really appreciate your responses and knowledge. Means a lot - I had to study a bit to understand things here and there. Thanks for that too. Appreciate your help.


weverson-luan
PRO

a month ago

I'm facing this problem and haven't been able to find a solution. Did you manage to find one? I'm thinking about switching to a different infrastructure because of this.


Anonymous
HOBBYOP

a month ago

Yeah, multiple people have raised this issue.. but Railway is not acknowledging it, let alone fixing it.

I don't think there's any solution as of now.. and we are also shifting to another infra.

You can also read this thread:

https://station.railway.com/questions/edge-hikari-intermittently-sends-rst-s-3ed8fbb0


25 days ago

Hey all, we have rolled out a fix for this. It turned out to be an issue with an upstream dependency.

Please let us know if you continue to see issues.


Status changed to Awaiting User Response Railway • 25 days ago


Railway
BOT

18 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway • 18 days ago


Anonymous
HOBBYOP

15 days ago

Hey @brody, I haven't got the notification of your reply.

But yes, this issue seems to be fixed now. Thank you.


Status changed to Open Railway • 15 days ago


Status changed to Solved Anonymous • 15 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...