{"record":{"id":"f70ce675f874303c","repo":"apache/rocketmq","slug":"no-name-server-exception","errorCode":"NO_NAME_SERVER_EXCEPTION","errorMessage":"No name server address, please set it.{}","messagePattern":"No name server address, please set it\\.(.+?)","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"critical","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java","lineNumber":732,"sourceCode":"        }\n\n        validateNameServerSetting();\n        throw new MQClientException(\"No route info for this topic, \" + msg.getTopic(), null);\n    }\n\n    public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName, final boolean resetIndex) {\n        return this.mqFaultStrategy.selectOneMessageQueue(tpInfo, lastBrokerName, resetIndex);\n    }\n\n    public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation,\n                                boolean reachable) {\n        this.mqFaultStrategy.updateFaultItem(brokerName, currentLatency, isolation, reachable);\n    }\n\n    private void validateNameServerSetting() throws MQClientException {\n        List<String> nsList = this.getMqClientFactory().getMQClientAPIImpl().getNameServerAddressList();\n        if (null == nsList || nsList.isEmpty()) {\n            throw new MQClientException(\n                \"No name server address, please set it.\" + FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL), null).setResponseCode(ClientErrorCode.NO_NAME_SERVER_EXCEPTION);\n        }\n\n    }\n\n    private SendResult sendDefaultImpl(\n        Message msg,\n        final CommunicationMode communicationMode,\n        final SendCallback sendCallback,\n        final long timeout\n    ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        this.makeSureStateOK();\n        Validators.checkMessage(msg, this.defaultMQProducer);\n        final long invokeID = random.nextLong();\n        long beginTimestampFirst = System.currentTimeMillis();\n        long beginTimestampPrev = beginTimestampFirst;\n        long endTimestamp = beginTimestampFirst;\n        TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java#L714-L750","documentation":"MQClientException with responseCode ClientErrorCode.NO_NAME_SERVER_EXCEPTION, thrown by validateNameServerSetting() when the client's remoting layer has an empty/null name server address list. It fires at send time (end of sendDefaultImpl / invokeMessageQueueSelector, after route lookup already failed) to give a clearer reason than 'no route': without a name server, no routes can ever be resolved. Response code lets programmatic handlers distinguish config errors from missing topics.","triggerScenarios":"triggerScenarios","commonSituations":"commonSituations","solutions":["Set the name server explicitly on the client: producer.setNamesrvAddr(\"10.0.0.1:9876;10.0.0.2:9876\") before start()","Or set the system property -Drocketmq.namesrv.addr=... / env NAMESRV_ADDR before the producer is constructed (property is read at client build time)","If using the 5.x gRPC client, set the nameserver for route discovery separately (namesrvAddr on ClientConfiguration) in addition to the gRPC endpoint","Verify at startup: log producer.getClientConfig() name server list and fail fast in your bootstrap if empty"],"exampleFix":"// before\nDefaultMQProducer p = new DefaultMQProducer(\"g\"); p.start(); p.send(msg); // no ns addr\n// after\nDefaultMQProducer p = new DefaultMQProducer(\"g\");\np.setNamesrvAddr(System.getenv(\"NAMESRV_ADDR\")); // e.g. 10.0.0.1:9876\np.start();\np.send(msg);","handlingStrategy":"validation","validationCode":" String ns = System.getProperty(\"rocketmq.namesrv.addr\", System.getenv(\"NAMESRV_ADDR\"));\nif (Strings.isNullOrEmpty(ns)) {\n    throw new ConfigurationException(\"Set rocketmq.namesrv.addr or NAMESRV_ADDR before starting the producer\");\n}\nDefaultMQProducer p = new DefaultMQProducer(group);\np.setNamesrvAddr(ns);","typeGuard":null,"tryCatchPattern":"try {\n    producer.send(msg);\n} catch (MQClientException e) {\n    if (e.getResponseCode() == ClientErrorCode.NO_NAME_SERVER_EXCEPTION) {\n        throw new ConfigurationException(\"RocketMQ name server address missing\", e);\n    }\n    throw e;\n}","preventionTips":["Always call setNamesrvAddr explicitly instead of relying on ambient properties","Add a startup assertion that the client's name server list is non-empty","Inject nameserver config via environment and validate it in the health endpoint","Distinguish NO_NAME_SERVER_EXCEPTION by response code in central error handling"],"tags":["rocketmq","configuration","nameserver","send"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}