---
title: not logged in
description: A luna command stops with exit code 3 because this machine has no login and no token was given.
related:
  - /cli/login
  - /develop/deploy-from-ci
  - /platforms/automate-with-api-tokens
---

A `luna` command stops before it reaches Luna, because it has nothing to act as. This happens on a new machine and in CI.

## Issue

The command prints this and exits with code 3.

```text
error: not logged in
  Run `luna login` (`luna signup` makes an account first), pass --token, or set LUNA_TOKEN.
```

## Cause

Each command that talks to Luna needs a credential. It looks in this order:

1. The `--token` flag.
2. The `LUNA_TOKEN` environment variable.
3. The login saved on this machine by `luna login` or `luna signup`.

None of the three was there. A script or a CI job has no saved login, so it needs a token.

A login or token that Luna no longer accepts fails a little differently. Luna answers 401, and the command adds this line under Luna's message. It also exits with code 3.

```text
  Log in again with `luna login`, or pass --token.
```

## Solution

On your own machine, log in. [`luna login`](/cli/login) opens the approval page in your browser and waits for you there.

```bash
luna login
```

Run [`luna signup`](/cli/signup) instead if you have no account yet. On a machine without a browser, add `--no-browser` and open the address it prints elsewhere.

In CI or a script, make an API token with the scopes the job needs, and set it as `LUNA_TOKEN`.

[Automate with API tokens](/platforms/automate-with-api-tokens) shows how to make one, and [Deploy from CI](/develop/deploy-from-ci) shows a whole workflow.
