title: MQJE001: An MQException occurred: Completion Code 2, Reason 2059 MQJE011: Socket connection attempt refused, couldn't access IBM MQ
body: <p><a href="https://i.stack.imgur.com/hAxmW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hAxmW.png" alt="ibm mq screenshot" /></a></p>
  <pre><code>
      public static void main(String[] args) {
          IBMMQTest obj = new IBMMQTest();
          obj.mqSend();
  
      }
      
      //method to connect and send message to Mq   
      public void mqSend(){
        try{
  
           //Create a Hashtable with required properties
           Hashtable properties = new Hashtable&lt;String, Object&gt;();
           properties.put(&quot;hostname&quot;, &quot;127.0.0.1&quot;);
           properties.put(&quot;port&quot;, &quot;1514&quot;);
           properties.put(&quot;channel&quot;, &quot;APPQ1&quot;); 
  
           //Create a instance of qManager
           MQQueueManager qMgr = new MQQueueManager(&quot;HBAX013D&quot;, properties);
  
           //Connect to the Queue
           MQQueue queue = qMgr.accessQueue(&quot;Q1&quot;, MQC.MQOO_OUTPUT);
  
           //Creating the mqmessage
           MQMessage mqMsg = new MQMessage();
           mqMsg.writeString(&quot;hello&quot;);
  
           MQPutMessageOptions pmo = new MQPutMessageOptions();
  
           queue.put(mqMsg,pmo);
  
           queue.close();
           qMgr.disconnect();
        }catch(MQException  mqEx){
           mqEx.printStackTrace();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      }
  
  }
  </code></pre>
  <p>When I try the command <code>dspmq</code>, I get the following result:</p>
  <pre><code>QMNAME(HBAX013D)                                          STATUS(Running)
  QMNAME(HBAX013DD)                                         STATUS(Running)
  QMNAME(TEST)                                              STATUS(Ended unexpectedly)
  QMNAME(TEST2)                                             STATUS(Ended unexpectedly)
  </code></pre>
  <p>My system ip: 10.25.25.7</p>
  <p>I am using Oracle Java 8</p>
  <p>When I try the command <code>telnet 127.0.0.1:1414</code> I get the following error:</p>
  <pre><code>Could not open connection to the host, on port 23: Connect failed. 
  </code></pre>