Error with Network Connection

I build a project with yarn and added rxjs 6.6.7 as dependency. In the last 3-4 weeks I noticed, that 80% of my builds failed due to network connection. The following error is visible in the logs:

yarn install v1.22.17
[1/4] Resolving packages…
[2/4] Fetching packages…
info There appears to be trouble with your network connection. Retrying…
info There appears to be trouble with your network connection. Retrying…
info There appears to be trouble with your network connection. Retrying…
info There appears to be trouble with your network connection. Retrying…
error An unexpected error occurred: “https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz: ESOCKETTIMEDOUT”.

I already set the timeout time to 300000, but still get that error. If I restart the build, if sometimes help, but most of the time it doesnt. I can build it locally without issues.