# MQRC 2002: Already connected

Source: https://wndsoftware.com/mainframe-errors/mqrc-2002

### MQRC 2002: Already connected

MQRC 2002 means the application is already connected to IBM MQ. Check connection ownership before adding a disconnect or retrying initialization.


#### Other names for this code

Also written as `RC2002`, `reason code 2002`, `MQ error 2002`, `MQRC_ALREADY_CONNECTED`, `07D2`, `0x07D2`.


### What it means

MQCONN or MQCONNX found an existing connection. IBM classifies this as MQCC_WARNING, rather than a failed connection attempt. The returned connection handle is the existing handle. A second successful-looking initialization does not give a helper routine ownership of that connection.

On distributed platforms, one thread cannot create a second nonshared connection handle. On z/OS this reason applies to batch and IMS, rather than CICS. Check the API and environment before changing a connection pool.


#### A troubleshooting example

A batch program connects once, then invokes a reporting library that also connects. The library receives 2002 and returns the same handle. If its cleanup disconnects that handle, the batch program loses its connection. The useful fix is an ownership change: the batch program connects and disconnects; the library receives a borrowed handle. A regression check should run two library calls in succession and then make a queue call from the original program. That catches the lifecycle mistake without requiring a production outage.


### Common causes

- A reusable subroutine calls MQCONN even though its caller already connected.
- Initialization runs twice after a configuration reload or an error path.
- A callback attempts a connection that conflicts with the connection already associated with its thread.


### How to find the problem

- Record the completion code as well as reason 2002. A wrapper that treats every nonzero reason as a failed connection hides this warning.
- Trace the first MQCONN or MQCONNX on the affected thread and compare its Hconn with the handle returned by the later call.
- Write down which component owns connection setup and teardown. Include framework lifecycle hooks and library cleanup routines.
- Reproduce one request with connection and disconnection logging. Look for an MQDISC from a helper immediately before unrelated queue calls fail.


### How to fix it

- Reuse the existing connection when that is the intended application design. Do not issue an extra MQDISC merely to balance the repeated connect call.
- Move connection ownership to one clearly defined component. Helpers that borrow a handle should not disconnect it.
- If independent connections are required, review supported handle-sharing options and threading rules for your installed MQ client. Test the intended design rather than repeatedly reconnecting.


### What it looks like


```text
Illustrative diagnostic notes; not an IBM message template.
Caller MQCONNX: CompCode=0
Library MQCONN: CompCode=1 Reason=2002
Check: did library cleanup disconnect the caller?
```


### IBM documentation

[IBM MQ 9.4: 2002 MQRC_ALREADY_CONNECTED](https://www.ibm.com/docs/en/ibm-mq/9.4.x?topic=codes-2002-07d2-rc2002-mqrc-already-connected). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Updated 2026-10-23. IBM documentation checked for this article. Written in our own words. For the full reference, check IBM’s MQ documentation for your version.


### Related codes

[MQRC 2009 MQRC_CONNECTION_BROKEN Read →](https://wndsoftware.com/mainframe-errors/mqrc-2009)
[MQRC 2018 MQRC_HCONN_ERROR Read →](https://wndsoftware.com/mainframe-errors/mqrc-2018)
[MQRC 2025 MQRC_MAX_CONNS_LIMIT_REACHED Read →](https://wndsoftware.com/mainframe-errors/mqrc-2025)

### Questions


#### Should I reconnect after MQRC 2002?

Not simply because of this warning. Check the returned handle and ownership. Reconnecting without correcting duplicate initialization can repeat the same problem.


#### Can I add an MQDISC to clear it?

That can disconnect the original caller too. Only the component that owns the connection should decide when it is safe to disconnect.

[IBM MQ reason codes](https://wndsoftware.com/mainframe-errors/mq-reason-codes) · [MQRC 2540](https://wndsoftware.com/mainframe-errors/mqrc-2540) · [MQRC 2003](https://wndsoftware.com/mainframe-errors/mqrc-2003)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
