简体   繁体   English

Spring 在 localhost 上启动应用程序:连接被拒绝

[英]Spring Boot app on localhost: connection refused

I have a Spring Boot app which runs fine 80% of the time.我有一个 Spring 启动应用程序,它在 80% 的时间内运行良好。

In the other 20% however, I get "refused to connect" errors on localhost.然而,在另外 20% 中,我在 localhost 上收到“拒绝连接”错误。 What I have tried:我试过的:

  • changing ports更改端口
  • turning windows defender/firewall completely off完全关闭 windows 防御者/防火墙
  • restarting重启

Nothing works.没有任何效果。 Then after a while when I keep the app running, it suddenly starts working again.然后在我保持应用程序运行一段时间后,它突然又开始工作了。

As you might know this is really bad for my workflow.您可能知道这对我的工作流程非常不利。 I only have had this problem with Spring Boot apps.我只有 Spring 引导应用程序有这个问题。

But if I check the logs, when trying to connect nothing gets logged: these connection attempts don't even reach my app.但是,如果我检查日志,则在尝试连接时不会记录任何内容:这些连接尝试甚至不会到达我的应用程序。 I'm running on an embedded server under Windows 10.我在 Windows 10 下的嵌入式服务器上运行。

It might be the server blocks incoming connections, and if so, why?可能是服务器阻止了传入连接,如果是这样,为什么?

Everything here runs on localhost.这里的一切都在 localhost 上运行。 Basically trying to open my spring boot app in chrome.基本上是试图在 chrome 中打开我的 spring 启动应用程序。 Yet neither chrome nor anything on the local network can reach my spring boot app.然而,chrome 和本地网络上的任何东西都无法访问我的 spring 启动应用程序。

Any ideas where to proceed with this?有什么想法可以继续进行吗?

I have figured this one out, so turns out, if you're using Quartz for task scheduling, Quartz WILL block your incoming requests in some way until it handles all the triggers it was supposed to fire while the server was off.我已经弄清楚了这一点,所以事实证明,如果您使用 Quartz 进行任务调度,Quartz 会以某种方式阻止您的传入请求,直到它处理所有应该在服务器关闭时触发的触发器。 So the longer you waited between runs the longer you have to wait while Quartz fixes itself.因此,您在运行之间等待的时间越长,您在 Quartz 自行修复时等待的时间就越长。 The solution for local work is simply to turn Quartz off unless you're debugging Quartz itself.本地工作的解决方案是简单地关闭 Quartz,除非您正在调试 Quartz 本身。

Super weird, took me months to understand it.超级奇怪,我花了几个月的时间才理解它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 docker镜像中的spring boot应用程序错误连接到localhost:5433被拒绝 - spring boot app in docker image error Connection to localhost:5433 refused JedisPool 连接拒绝 Spring Boot - JedisPool Connection Refused Spring Boot 连接拒绝从 Spring 启动应用程序容器到 Rabbitmq 容器 - Connection Refused to Rabbitmq container from Spring boot app Container Docker 组成 Redis 和 Spring 启动应用程序:java.net.ConnectException:连接被拒绝(连接被拒绝)“, - Docker compose Redis and Spring boot app: java.net.ConnectException: Connection refused (Connection refused)", finishConnect(..) 失败:连接被拒绝:localhost/127.0.0.1,错误:Webflux、Webclient、Spring 启动、java - finishConnect(..) failed: Connection refused: localhost/127.0.0.1 , error: Webflux, Webclient, Spring boot, java spring 启动连接到 localhost 数据库 - spring boot connection to localhost database Spring App cloudfoundry:连接被拒绝 - Spring App cloudfoundry : connection refused Spring 引导 MySQL Docker ConnectException:连接被拒绝 - Spring Boot MySQL Docker ConnectException: Connection refused 春季启动-嵌入式mongodb连接被拒绝 - spring boot - embedded mongodb connection refused Redis 运行时连接被拒绝 Spring 启动 - Redis Connection refused When Run Spring Boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM