Cursor-agent cli mistakenly reports invalid CURSOR_API_KEY upon dns resolution failure

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

When cursor-agent cli receives a prompt request, if the DNS lookup of the cursor endpoint fails, instead of issuing a clear “failed to resolve endpoint of ap2.cursor.sh blah” it instead gives the misleading error:

Warning: The provided API key is invalid.
The API key was loaded from the CURSOR_API_KEY environment variable.
Please check you have the right key, create a new one, or authenticate without it.

This seems to imply successful communication with the endpoint, and positive invalidation of the api key value, when in reality, it did zero https requests.

This can cause a lot of sadness and mispent time debugging the entirely incorrect thing.

Solution would be to catch DNS resolution errors and in general, all HTTPS communication errors and raise those relevant issues up as errors rather than what is a non-sequitur.

$ ~/.local/bin/cursor-agent -v
2026.01.28-fd13201

Steps to Reproduce

In my case, I was running it in a container without proper dns resolution.

Expected Behavior

A clear error that correctly signals difficulty in communicating with the endpoint, and the relevant step that failed.

Operating System

Linux

Version Information

2026.01.28-fd13201

Does this stop you from using Cursor

Yes - Cursor is unusable

Thanks for the report @Kyle_Bresin! I can reproduce this and I agree we should have better logging here. I’ve filed a bug.

1 Like