Nacos报错,failed to req API:/nacos/v1/ns/instance after all servers([localhost:8848]) tried: failed to

这篇具有很好参考价值的文章主要介绍了Nacos报错,failed to req API:/nacos/v1/ns/instance after all servers([localhost:8848]) tried: failed to。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.Nacos单机启动报错

java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([localhost:8848]) tried: failed to req API:localhost:8848/nacos/v1/ns/instance. code:500 msg: java.net.ConnectException: Connection refused: connect
	at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:464) ~[nacos-client-1.1.1.jar:na]
	at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:386) ~[nacos-client-1.1.1.jar:na]
	at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:188) ~[nacos-client-1.1.1.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:205) ~[nacos-client-1.1.1.jar:na]
	at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:184) ~[nacos-client-1.1.1.jar:na]
	at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:61) ~[spring-cloud-alibaba-nacos-discovery-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:239) [spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:74) [spring-cloud-alibaba-nacos-discovery-2.1.0.RELEASE.jar:2.1.0.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:138) [spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.bind(AbstractAutoServiceRegistration.java:101) [spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:88) [spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:47) [spring-cloud-commons-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:165) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
	at com.apple.springcloud.PaymentMain9003.main(PaymentMain9003.java:12) [classes/:na]

2.前提配置

  1. 引入依赖
<!-- nacos-discovery -->
<dependency>
 	<groupId>com.alibaba.cloud</groupId>
 	<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
 	<groupId>org.springframework.boot</groupId>
 	<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
 	<groupId>org.springframework.boot</groupId>
 	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  1. application.yml
server:
 port: 9003

spring:
 application:
   name: nacos-payment-provider
 cloud:
   nacos:
     discovery:
       server-addr: localhost:8848		#配置Nacos地址

management:
 endpoints:
   web:
     exposure:
       include: '*'
  1. 主启动类加上@EnableDiscoveryClient注解

3.我的解决

  1. 开启Nacos服务
  2. 再次检查yml文件配置,注意缩进
  3. 我查询了很多网上的文章,最后都没有解决,后来我决定先访问 http://localhost:8848/nacos/#/login 试一下,发现Nacos报错,是跟数据库相关的,“No DataSource set”,然后我想起来之前配置了Nacos持久化,所以访问的是mysql,于是——>开启mysql服务——>重启Nacos——>大功告成

文章来源地址https://www.toymoban.com/news/detail-608703.html

到了这里,关于Nacos报错,failed to req API:/nacos/v1/ns/instance after all servers([localhost:8848]) tried: failed to的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • nacos作为注册中心: Application failed to connect to Nacos server: “xxxx“

    1、首先排查nacos是否启动成功 2、排查nacos映射的地址是哪个 3、如果是服务之间互相引用,nacos有公共地址的,排查连接nacos配置文件的ip是否正确 4、如果nacos配置文件正确,则需要对公共的服务进行install,这样新服务才会引用到 上述问题中我遇到的是第四个情景,按照自己

    2024年01月21日
    浏览(52)
  • nacos启动报错org.apache.derby.iapi.error.StandardException: Another instance of

    nacos版本2.1.1 一开始是因为nacos配置中心访问发现所有的配置数据全不见了,去检查了mysql发现所有的配置都在,就想着用重启的方式去解决这个问题,然而在重启过程又发现了一系列的问题,所以记录一下仅供参考。 以下异常信息都是在start.out日志中查看的。       在l

    2024年02月13日
    浏览(30)
  • Nacos 版本不一致报错: Request nacos server failed

    在做微服务开发中,测试环境使用Nacos没有问题,但是生产环境服务启动一直报错: 代码没有改动,测试环境没问题,但是生产环境有问题呢?首先看一下两者不同的地方,大多数都是 环境配置 的问题。 查看 Nacos 服务的版本,查看 Nacos 控制台首页左上角就能看到版本号:

    2024年02月12日
    浏览(34)
  • 解决报错:Failed to connect to github.com port 443 after 21073 ms

     今天在连接github仓库时遇到了一个报错:  Failed to connect to github.com port 443 after 21073 ms: Timed out(译为:21073 毫秒后无法连接到 github.com 端口 443:超时)。 原因: 这样的问题往往是由于网络慢访问超时,这时候我们可以在终端选择使用设置代理和取消代理的命令解决。

    2024年02月16日
    浏览(33)
  • github上传遇到的 Failed to connect to github.com port 443 after ** ms: Timed out 报错

    遇到这种报错,往往是由于 Git 代理设置出现问题,按照以下操作重新配置代理: 1.取消原代理设置 命令行输入 2.刷新 DNS 解析缓存 命令行输入 3.重新设置代理 命令行输入 4. 补充 配置中的7890端口需要和电脑的代理端口吻合。打开:设置 -- 网络与Internet -- 代理(Windows10直接

    2024年02月08日
    浏览(36)
  • git 报错Failed to connect to github.com port 443 after 21224 ms: Timed out 解决办法

    在 git clone 或者 git push 时,一直报错 Failed to connect to github.com port 443 after xxx ms: Timed out 网页可以正常打开github 电脑连接VPN Windows、Linux、Mac OS 中 git 命令相同: 设置代理命令: 注意事项: 命令中的主机号(127.0.0.1)是使用的代理的主机号,如果代理软件运行在本机则填入1

    2024年02月01日
    浏览(64)
  • [报错解决] Failed to connect to github.com port 443 after ***** ms: Couldn‘t connect to server

    今天想把自己有关文件格式转换的Python脚本上传到github上,但是无奈遇到报错: 这是由于本机系统代理端口和git端口不一致导致的。 解决办法: 一、查看自己本机系统代理: 设置---网络和Internet---代理---地址:端口  二、修改git配置:(其中的10809改为你电脑的端口号) 三、

    2024年02月11日
    浏览(41)
  • Git报错 -> Failed to connect to github.com port 443 after ***** ms: Couldn‘t connect to server

    这是由于本机系统代理端口和git端口不一致导致的。 查看本机端口 修改git端口 再次push [报错解决] Failed to connect to github.com port 443 after ***** ms: Couldn‘t connect to server

    2024年02月06日
    浏览(47)
  • 记录nacos一次踩坑经历,报错 403 authorization failed! unknown user

    本人在学习springcloud alibaba时配置nacos的时候,如果未开启权限认证是正常的 nacos server中的配置: 代码中服务发现配置: nacos server中客户端管理页面中的配置: 项目启动类: 项目启动后可以正常读取到结果 接下来就恶心了,开启权限,修改nacos server中application.properties文件中(这里修改

    2024年02月06日
    浏览(44)
  • nacos下线服务报错:caused: errCode: 500, errMsg: do metadata operation failed ;caused: com.alibaba.nacos.co

    使用nacos下线一个节点的服务时,弹窗报错: 1、先停掉nacos 2、到nacos安装目录下,找到data-protocal 3、把protocal整个文件夹删了,然后重启nacos就行了

    2024年02月12日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包