DEV Community

Cover image for Spring Gateway — Connection prematurely closed
Maxime Guilbert
Maxime Guilbert

Posted on • Edited on

7 2

Spring Gateway — Connection prematurely closed

During your working on a Spring Gateway, you can have this kind of issue which seems to come from out of nowhere:

 reactor.netty.http.client.PrematureCloseException: Connection prematurely closed DURING response
Enter fullscreen mode Exit fullscreen mode

After reviewing a lot of GitHub or StackOverflow pages, the only things I saw to correct it was to update the netty library (In the case of Spring Gateway, update the spring library because it embeds netty.) or to update some configs.

But maybe it won’t help you that much. If you continue to have this issue, check your infrastructure.

In our case, our load balancers were the problem.

For some reason, we changed our CLB (Classic Load Balancers) for NLB (Network Load Balancer) in AWS. But the default configuration wasn’t correct for our usage. So we randomly had this “Connection prematurely closed” error. Then, when we go back to CLB, it worked well.

Currently, I didn’t take the time to explore why this is happening with NLB, but I really want to share this point that I never saw anywhere else. I hope it will help you!


Links to PrematureCloseException issues in GitHub :

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)