Troubleshooting
Troubleshooting
Section titled “Troubleshooting”Solutions to common issues.
Setup Problems
Section titled “Setup Problems”“credentials.json not found”
Section titled ““credentials.json not found””Your Google OAuth client file is missing.
Solution:
- Go to Google Cloud Console
- Enable Gmail API: APIs & Services → Library → search “Gmail” → Enable
- Create OAuth client: APIs & Services → Credentials → Create Credentials → OAuth client ID → Desktop app
- Download JSON → save as
secrets/credentials.json
“Access denied” during authorization
Section titled ““Access denied” during authorization”Google blocked your app because it’s in Testing mode.
Solution:
- In Google Cloud Console, go to APIs & Services → OAuth consent screen
- Under “Test users,” add your Gmail address
- Run
python authorize.pyagain
“Port already in use”
Section titled ““Port already in use””Your system’s port 8080 is taken.
Solution: The script picks a random port automatically. If it fails, find the culprit:
lsof -i :8080kill -9 <PID>python authorize.py # try againToken expired or invalid
Section titled “Token expired or invalid”OAuth tokens expire. Re-authorize:
python authorize.pyThis creates a fresh secrets/token.json.
Deployment Issues
Section titled “Deployment Issues”“Connection refused” from ChatGPT
Section titled ““Connection refused” from ChatGPT”ChatGPT can’t reach your server.
Checklist:
- Is your reverse proxy (Caddy/Nginx) running?
- Does DNS resolve your domain correctly?
- Is the HTTPS certificate valid?
- Are ports 80/443 open in your firewall?
- Is Docker container running?
docker compose ps
Test:
curl -I https://your-domain/mcpContainer won’t start
Section titled “Container won’t start”Check logs:
docker compose logs gmail-mcpCommon causes:
- Missing
.envfile - Missing
secrets/credentials.json - Port 8811 already in use
- Bad permissions on
secrets/directory
Fix permissions:
chmod 755 secrets/docker compose down && docker compose up -d --build“OAuth passphrase incorrect”
Section titled ““OAuth passphrase incorrect””You entered wrong passphrase or it changed.
Solution:
- Check
.envforGMAIL_MCP_OAUTH_PASSPHRASE - Restart container:
docker compose restart gmail-mcp - If you forgot it, generate new:
Update
Terminal window python -c "import secrets; print(secrets.token_urlsafe(24))".envand restart.
“OAuth client ID mismatch”
Section titled ““OAuth client ID mismatch””Your ChatGPT connector client ID doesn’t match .env.
Solution:
- In
.env, findGMAIL_MCP_OAUTH_CLIENT_ID - In ChatGPT connector settings, paste this exact ID
- Restart:
docker compose restart gmail-mcp
Claude Code Issues
Section titled “Claude Code Issues”Gmail tools don’t appear in Claude Code
Section titled “Gmail tools don’t appear in Claude Code”Checklist:
- Is server running?
python -m gmail_mcp.server - Is it in Claude Code settings? Check
~/.claude/settings.json - Did you restart Claude Code after adding it?
Local setup syntax:
{ "mcpServers": { "gmail": { "command": "python", "args": ["-m", "gmail_mcp.server"], "cwd": "/full/path/to/gmail-mcp-server" } }}“gmailSearchMessages: Invalid OAuth token”
Section titled ““gmailSearchMessages: Invalid OAuth token””Your token expired (local mode).
Solution:
python authorize.pyRestart Claude Code.
Slow responses
Section titled “Slow responses”Gmail’s API is the bottleneck, not this server. Large mailboxes take time.
Speed up:
- Use specific search filters:
is:unread from:bossinstead of broad queries - Search recent messages:
after:2024/01/01
Debug Mode
Section titled “Debug Mode”See detailed logs:
Local:
LOGLEVEL=debug python -m gmail_mcp.serverDocker:
docker compose exec gmail-mcp shLOGLEVEL=debug python -m gmail_mcp.serverPrints all API calls and token refreshes—useful for tracking auth issues.
Still stuck? Check your .env file exists, secrets/credentials.json is readable, and your Google account is added as a test user.
