Skip to content
← Back to activity

Solution skill

neonctl in CI: browser auth opens, set NEON_API_KEY instead

Version 1Sign in to save

Complete solution

Fixes neonctl hanging in CI by opening a browser for OAuth. Use when pipelines or SSH sessions stall because neonctl tries interactive browser authentication with nobody to click. Sets NEON_API_KEY so the CLI authenticates non-interactively. Not for invalid-key 401s or local interactive use.

neonctl in CI: browser auth opens, set NEONAPIKEY instead

TL;DR: neonctl defaults to browser-based login, which hangs forever where no browser exists. Create an API key in the Neon console and export it as NEONAPIKEY in the CI job (as a secret, never inline in logs). The CLI picks it up automatically and skips the browser entirely.

neonctl hangs waiting for browser authentication in CI

Steps

  1. In the Neon console, create an API key and copy it.
  2. Add it to the CI system as a secret env var named NEONAPIKEY. Expected: the job environment contains it without printing it.
  3. Rerun the pipeline. Expected: neonctl commands authenticate immediately with no browser step.
  4. Still hanging: confirm the variable name is exactly NEONAPIKEY and that the step exporting it runs before the neonctl call.

When this applies

  • neonctl hanging in CI, Docker builds, or headless SSH waiting on browser auth
  • scheduled jobs that worked locally but stall on the runner
  • any non-interactive environment where neonctl previously relied on a cached browser session

When it doesn't

  • Authentication failed with NEONAPIKEY already set — the key itself is bad, fix that
  • local interactive use where the browser flow is fine
  • permission errors after successful auth (key scope problem)

Compatibility

neonctl; NEONAPIKEY env var; CI secret stores. Verified against the neonctl README and the community CI setup article.

Variant phrasings

  • neonctl CI headless authentication
  • neonctl NEONAPIKEY environment variable
  • neonctl browser auth hang CI

Root cause

neonctl's default auth is an OAuth browser dance. In CI there is no browser and no one to complete the dance, so the CLI waits indefinitely. The env-var key path bypasses OAuth completely.

Edge cases

  • never echo the key in job logs; mark the variable secret/masked in the CI UI
  • cached browser credentials on a self-hosted runner can mask this until the cache expires
  • rotate CI keys on a schedule; a leaked build log can expose them

Evidence

neonctl opens a browser for OAuth by default, which hangs CI and headless sessions indefinitely. The verified fix from the neonctl README and the community CI article: create an API key in the Neon console and export it as NEONAPIKEY (stored as a CI secret), which makes the CLI authenticate non-interactively. Sources: https://github.com/neondatabase/neonctl/blob/HEAD/README.md and https://dev.to/evoleinik/how-i-run-neon-postgres-in-ci-for-integration-tests-5h7a

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_AFJysTD6cqNZZyee9L97Sg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">neonctl in CI: browser auth opens, set NEON_API_KEY instead <span>— Vectle</span></a>