server command group provides control over the Infrahub API server. These commands are used to start and manage the FastAPI-based API server that handles GraphQL and REST requests.
Command Overview
start
Start the Infrahub API server in debug mode with automatic reload.Options
| Option | Type | Description | Default |
|---|---|---|---|
--listen | string | Address to listen for new requests | 127.0.0.1 |
--port | integer | Port to listen for new requests | 8000 |
--debug | boolean | Enable debug logging and auto-reload | False |
Environment Variables
INFRAHUB_CONFIG- Path to configuration file (defaults toinfrahub.toml)
Examples
Basic Server Start
Start the server with default settings:http://127.0.0.1:8000 without auto-reload.
Debug Mode with Auto-Reload
Start the server with debug logging and automatic code reload:--debug enabled:
- Code changes automatically trigger server reload
- Excludes
examples/andrepositories/directories from reload watching - Enables detailed logging
Custom Listen Address and Port
Bind to all interfaces on a custom port:Development Workflow
Typical development server usage:With Custom Configuration
Use a specific configuration file:How It Works
Theserver start command:
- Loads configuration from the specified or default config file
- Initializes the FastAPI application
- Configures logging with custom formatters
- Starts Uvicorn ASGI server
- In debug mode, enables file watching for auto-reload
Server Architecture
The Infrahub API server provides:- GraphQL API - Primary query and mutation interface
- REST API - Alternative HTTP-based interface
- WebSocket Support - For real-time subscriptions
- Static File Serving - Frontend assets and documentation
Logging Configuration
The server uses custom log formatting:- uvicorn.error - Server errors and warnings
- uvicorn.access - HTTP request access logs
Production Deployment
For production, use Gunicorn with Uvicorn workers instead ofserver start:
- Multiple worker processes
- Better performance under load
- Automatic worker restart on failure
- Production-grade logging
Troubleshooting
Port Already in Use
If you see:Neo4j Connection Issues
If the server fails to start with database errors:infrahub.toml:
Permission Denied on Port 80/443
Binding to privileged ports requires root or capabilities:API Endpoints
Once started, the server exposes:| Endpoint | Description |
|---|---|
/graphql | GraphQL API endpoint |
/api/* | REST API endpoints |
/api/docs | OpenAPI/Swagger documentation |
/api/schema | OpenAPI schema JSON |
/ | Frontend application (if built) |
Health Checks
Test if the server is running:See Also
- Database Commands - Manage the graph database
- infrahubctl Commands - Complete CLI reference
- CLI Overview - Introduction to the CLI