title: IBM MQ JMSWMQ0018: Failed to connect to queue manager 'MY_LOCAL_QM' with connection mode 'Client' and host name 'MY_LOCAL_QM(1401)'
body: <p>I created a queue manager, queue, channel(Server-connection).
  When I try to send a message, see this error:
  com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'MY_LOCAL_QM' with connection mode 'Client' and host name 'epspa(1401)'.
  Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.</p>
  
  <p>Maybe I need to set a user to queue manager? Because I use the same java code, but try to connect to another queue manager, and it works fine. But it doesn't work with my queue manager. 
  IBM MQ installed on another PC.</p>
  
  <pre><code> private static final String HOST = "epspa";
  private static final int PORT = 1401;
  private static final String CHANNEL = "API.SVRCONN_LOCAL";
  private static final String QMN = "MY_LOCAL_QM";
  private static final String QUEUE_NAME = "API.QUEUE_NAME";
  private static final String message ="message";
  
  public static String sendMessage(String message) {
      String result = "Error";
      try {
          MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
          cf.setHostName(HOST);
          cf.setChannel(CHANNEL);
          cf.setPort(PORT);
          cf.setQueueManager(QMN);
          cf.setTransportType(WMQConstants.WMQ_MESSAGE_BODY_MQ);
  
          Destination destination = null;
          MessageProducer producer = null;
  
          Connection c = cf.createConnection();
          Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
          destination = s.createQueue(QUEUE_NAME);
          producer = s.createProducer(destination);
          TextMessage tmo = s.createTextMessage();
  
  
          ((MQDestination) destination).setMessageBodyStyle
                  (WMQConstants.WMQ_MESSAGE_BODY_MQ);
  
          tmo.setIntProperty(WMQConstants.JMS_IBM_CHARACTER_SET, 1208);
          tmo.setIntProperty(WMQConstants.JMS_IBM_ENCODING,546);
          tmo.setText(message);
          producer.send(tmo);
  
          result = "Success!";
      } catch (JMSException e) {
          e.printStackTrace();
      } catch (Exception e) {
          e.printStackTrace();
      }
      return result;
  }
  </code></pre>