# MQRC 2040: Handle not open to set attributes

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

### MQRC 2040: Handle not open to set attributes

MQRC 2040 means MQSET used a handle without set capability. Review MQOO_SET and whether changing the queue attribute is appropriate for this program.


#### Other names for this code

Also written as `RC2040`, `reason code 2040`, `MQ error 2040`, `MQRC_NOT_OPEN_FOR_SET`, `07F8`, `0x07F8`.


### What it means

MQSET changes supported object attributes through a handle opened with MQOO_SET. Inquiry access does not imply permission or capability to modify those attributes.

IBM also documents that MQSET is not supported for Multicast topic handles. Distinguish an unsupported operation from an ordinary queue open that omitted the required option.


#### A troubleshooting example

A monitoring tool reads a queue attribute and later adds a button to change it. Its existing inquiry handle returns 2040 on MQSET. Before adding MQOO_SET, decide which users should be allowed to make that change and how the tool confirms the target queue. Test against a dedicated queue and read the value back afterward. This checks both technical success and targeting: an administrative action against the wrong environment can be more serious than the original reason code.


### Common causes

- A management utility opens for inquiry, then tries to change an attribute on the same handle.
- The application assumes output access also includes administrative changes.
- The handle represents an object or messaging model that does not support the requested set operation.


### How to find the problem

- Identify the attribute and value being changed, the target object and the handle used. Preserve this information before retrying.
- Locate the original MQOPEN and inspect its options. Check for a separate management handle that the code should have used.
- Confirm that the specific attribute can be changed by MQSET on this object and release. MQSET is not a general replacement for every MQSC command.
- Review who is authorized to change the attribute. A new set-capable open should not become an accidental privilege expansion in a routine producer.


### How to fix it

- For an approved supported change, obtain a handle with MQOO_SET and appropriate authority. Close it when the management task completes.
- Keep operational configuration changes outside the ordinary message loop where possible. A transient processing error should not silently reconfigure shared queues.
- Test the previous and new attribute values and provide a deliberate recovery path. Confirm other producers and consumers still behave as expected.


### What it looks like


```text
Illustrative diagnostic notes; not an IBM message template.
MQOPEN: MQOO_INQUIRE
MQSET: Reason=2040
Check approved attribute change and MQOO_SET.
```


### IBM documentation

[IBM MQ 9.4: 2040 MQRC_NOT_OPEN_FOR_SET](https://www.ibm.com/docs/en/ibm-mq/9.4.x?topic=codes-2040-07f8-rc2040-mqrc-not-open-set). 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 2038 MQRC_NOT_OPEN_FOR_INQUIRE Read →](https://wndsoftware.com/mainframe-errors/mqrc-2038)
[MQRC 2035 MQRC_NOT_AUTHORIZED Read →](https://wndsoftware.com/mainframe-errors/mqrc-2035)
[MQRC 2045 MQRC_OPTION_NOT_VALID_FOR_TYPE Read →](https://wndsoftware.com/mainframe-errors/mqrc-2045)

### Questions


#### Does inquiry imply set access?

No. They are different open capabilities and may require different authority.


#### Should every application open with MQOO_SET?

No. Request only capabilities needed for its approved function. Most producers do not need to change queue attributes.

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

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