> ## Documentation Index
> Fetch the complete documentation index at: https://thenile.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Development

The `nile local` command helps you manage a local development environment using Docker. This environment provides a PostgreSQL database pre-configured with Nile's schema and features.

## Overview

```bash theme={null}
nile local [command] [options]
```

Available commands:

* `start` - Start the local environment
* `stop` - Stop the local environment
* `info` - Display connection information

## Prerequisites

Before using the local environment, ensure you have:

1. Docker installed and running
2. PostgreSQL client tools (psql) installed
3. Sufficient permissions to run Docker commands

```bash Prerequisites Check theme={null}
# Check Docker installation
docker --version

# Check PostgreSQL tools
psql --version
```

## Starting the Environment

The `start` command launches a Docker container with a pre-configured PostgreSQL database.

```bash theme={null}
nile local start [options]
```

### Options

| Flag          | Description                                 | Default |
| ------------- | ------------------------------------------- | ------- |
| `--no-prompt` | Start without prompting for psql connection | false   |

### Examples

```bash Start Examples theme={null}
# Start with interactive prompt
nile local start

# Start without psql prompt
nile local start --no-prompt
```

### Sample Output

```bash Start Output theme={null}
✓ Latest Nile testing container pulled successfully
✓ Database is ready
✓ Local development environment started successfully

Connection Information:
Host:     localhost
Port:     5432
Database: test
Username: 00000000-0000-0000-0000-000000000000
Password: password

Would you like to connect using psql? (y/N)
```

## Stopping the Environment

The `stop` command gracefully stops and removes the Docker container.

```bash theme={null}
nile local stop
```

### Examples

```bash Stop Examples theme={null}
# Stop the environment
nile local stop
```

### Sample Output

```bash Stop Output theme={null}
✓ Local environment stopped successfully
```

## Viewing Connection Information

The `info` command displays connection details for the running environment.

```bash theme={null}
nile local info
```

### Examples

```bash Info Examples theme={null}
# Show connection information
nile local info

# Show with debug information
nile local info --debug
```

### Sample Output

```bash Info Output theme={null}
Connection Information:
Host:     localhost
Port:     5432
Database: test
Username: 00000000-0000-0000-0000-000000000000
Password: password
```

## Common Workflows

### Starting Development Session

```bash Development Setup theme={null}
# 1. Start the environment
nile local start

# 2. Connect using psql (if prompted)
# Or use connection information with your preferred client

# 3. Start development

# 4. Stop when finished
nile local stop
```

### Using with Database Tools

```bash Database Tools theme={null}
# Get connection information
nile local info

# Use with your preferred database tool
# Example: TablePlus, DBeaver, pgAdmin, etc.
```

### Debugging Connection Issues

```bash Debug Example theme={null}
# Start with debug output
nile local start --debug

# Check connection information
nile local info --debug
```

## Common Issues

### Container Already Running

```bash Container Running theme={null}
# Start attempt with existing container
nile local start
Error: A Nile local environment is already running

# Solution: Stop existing container
nile local stop
```

### PostgreSQL Client Missing

```bash Missing PSQL theme={null}
# When psql is not installed
Error: Failed to launch psql

# Solution: Install PostgreSQL client tools
# macOS:
brew install postgresql

# Ubuntu:
sudo apt-get install postgresql-client
```

### Docker Not Running

```bash Docker Not Running theme={null}
# When Docker daemon is not running
Error: Docker failed to start

# Solution: Start Docker daemon
# macOS: Start Docker Desktop
# Linux: sudo systemctl start docker
```

## Best Practices

1. **Clean Environment**: Always stop the environment when not in use:

   ```bash theme={null}
   nile local stop
   ```

2. **Connection Management**: Save connection information for reuse:

   ```bash theme={null}
   nile local info > connection.txt
   ```

3. **Debug Mode**: Use debug flag when encountering issues:
   ```bash theme={null}
   nile local start --debug
   ```

## Related Commands

* `nile db` - Manage cloud databases
* `nile tenants` - Manage tenants
* `nile users` - Manage users
* `nile config` - Configure CLI settings

## Environment Variables

The local environment uses these default values:

```bash Environment theme={null}
POSTGRES_USER=00000000-0000-0000-0000-000000000000
POSTGRES_PASSWORD=password
POSTGRES_DB=test
POSTGRES_PORT=5432
```

## Security Notes

1. The local environment is for development only
2. Default credentials should never be used in production
3. The environment is not encrypted by default
4. Container is accessible only from localhost
