Lesson 3 — Self-Hosting Firecrawl
Self-hosting is the best choice when you have high-volume scraping needs or sensitive data requirements.
3.1 Option A: Docker Deployment (Recommended)
This is the simplest and most stable method, as all dependencies run inside containers.
1. Clone the Repository and Configure
git clone https://github.com/firecrawl/firecrawl.git
cd firecrawl
cp apps/api/.env.example apps/api/.env
2. Minimal Environment Configuration
Edit apps/api/.env and ensure the following are set:
USE_DB_AUTHENTICATION=false(Usually disabled for local use)PORT=3002
3. Start the Services
docker compose up
This starts Redis, PostgreSQL, the API Server, and Workers. Visit http://localhost:3002/test; if you see "Hello, world!", the setup was successful.
3.2 Option B: Source Compilation
Use this method if you need to modify the code or perform deep debugging.
Prerequisites:
- Node.js 18+ & pnpm
- Redis 7+ (Task queue)
- PostgreSQL 15+ (Data storage)
Core Steps:
- Database Initialization: Build and start the database with the schema using the Dockerfile in
apps/nuq-postgres. - Install Dependencies: Run
pnpm installin the root directory. - Environment Variables: Same as the Docker method, but point
REDIS_URLandDATABASE_URLto your local instances. - Start: Run
pnpm startin theapps/apidirectory.
3.3 Configuring Local MCP Connection
To use your self-hosted Firecrawl in Claude Code, adjust your configuration:
{
"mcpServers": {
"firecrawl-local": {
"command": "npx",
"args": ["-y", "firecrawl-mcp"],
"env": {
"FIRECRAWL_API_URL": "http://localhost:3002",
"FIRECRAWL_API_KEY": ""
}
}
}
}
Note: In local mode, if
USE_DB_AUTHENTICATIONis disabled, theFIRECRAWL_API_KEYcan be left empty.
3.4 Troubleshooting
- ECONNREFUSED: Usually means Redis or PostgreSQL is not running.
- NUQ_DATABASE_URL Error: Ensure the correct schema is initialized in the database.
- Scraping Failure: Local mode lacks a global proxy pool by default and is limited by your current local network environment.