# Cursor-agent cli mistakenly reports invalid CURSOR\_API\_KEY upon dns resolution failure

**URL:** <https://forum.cursor.com/t/cursor-agent-cli-mistakenly-reports-invalid-cursor-api-key-upon-dns-resolution-failure/150412>\
**Category:** Bug Reports\
**Tags:** cli, linux\
**Created:** [January 30, 2026, 7:03pm UTC](https://forum.cursor.com/t/cursor-agent-cli-mistakenly-reports-invalid-cursor-api-key-upon-dns-resolution-failure/150412 "2026-01-30T19:03:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Bresin](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@Kyle\_Bresin](https://forum.cursor.com/u/Kyle_Bresin)\
**Post date:** [January 30, 2026, 7:03pm UTC](https://forum.cursor.com/t/cursor-agent-cli-mistakenly-reports-invalid-cursor-api-key-upon-dns-resolution-failure/150412/1 "2026-01-30T19:03:24Z")

</div>

### 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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [January 30, 2026, 7:26pm UTC](https://forum.cursor.com/t/cursor-agent-cli-mistakenly-reports-invalid-cursor-api-key-upon-dns-resolution-failure/150412/3 "2026-01-30T19:26:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [February 21, 2026, 7:27pm UTC](https://forum.cursor.com/t/cursor-agent-cli-mistakenly-reports-invalid-cursor-api-key-upon-dns-resolution-failure/150412/5 "2026-02-21T19:27:44Z")

</div>

Closed on February 21, 2026, 7:27pm UTC

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
