Table of contents
1. Problem phenomenon
When Nacos is restarted (in most cases because the machine is restarted) and then the service of the microservice project is started, the following exception will appear on the backend console:
NacosException: failed to req API:/api//nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried: server is DOWN now, please try again later!
2. Solution
There are two solutions available for reference:
1. If no special configuration has been made
Just delete (or rename) the protocol folder directly
The protocol folder is in the following location of the installation directory:
...\nacos-server-1.4.0\data\
2. If there is special configuration
Modify the IP in the files raft_meta and __raft_snapshot_meta
The locations of raft_meta and __raft_snapshot_meta are as follows:
...\nacos-server-1.4.0\data\protocol\raft\naming_persistent_service\meta-data
...\nacos-server-1.4.0\data\protocol\raft\naming_persistent_service\snapshot\snapshot_7(此处可能不是_7,视具体情况而定)
3. Precautions
The IP must be checked carefully and should be modified to the current IP of the machine where Nacos is located.
4. Partial exception records
During this exception handling process, some exception records that occurred are as follows:
2021-02-21 12:24:04.729 INFO 15344 --- [ restartedMain] com.alibaba.nacos.client.naming : [REGISTER-SERVICE] public registering service DEFAULT_GROUP@@hotbuy-orders with instance: {
"clusterName":"DEFAULT","enabled":true,"ephemeral":true,"healthy":true,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ip":"192.168.0.104","ipDeleteTimeout":30000,"metadata":{
"preserved.register.source":"SPRING_CLOUD"},"port":7000,"weight":1.0}
2021-02-21 12:24:04.754 ERROR 15344 --- [ restartedMain] com.alibaba.nacos.client.naming : request: /nacos/v1/ns/instance failed, servers: [127.0.0.1:8848], code: 503, msg: server is DOWN now, please try again later!
2021-02-21 12:24:04.761 ERROR 15344 --- [ restartedMain] c.a.c.n.registry.NacosServiceRegistry : nacos registry, hotbuy-orders register failed...NacosRegistration{
nacosDiscoveryProperties=NacosDiscoveryProperties{
serverAddr='127.0.0.1:8848', endpoint='', namespace='', watchDelay=30000, logName='', service='hotbuy-orders', weight=1.0, clusterName='DEFAULT', group='DEFAULT_GROUP', namingLoadCacheAtStart='false', metadata={preserved.register.source=SPRING_CLOUD}, registerEnabled=true, ip='192.168.0.104', networkInterface='', port=7000, secure=false, accessKey='', secretKey='', heartBeatInterval=null, heartBeatTimeout=null, ipDeleteTimeout=null}},com.alibaba.nacos.api.exception.NacosException: failed to req API:/api//nacos/v1/ns/instance after all servers([127.0.0.1:8848]) tried: server is DOWN now, please try again later!