Troubleshooting Guide
This guide covers common issues you may encounter when using mockd and how to resolve them.
Mock Not Matching
Section titled “Mock Not Matching”Common reasons why your mock might not be matching:
- Method mismatch - Check GET vs POST vs PUT
- Path mismatch - Check exact path, trailing slashes
- Mock not enabled - Check
enabled: true - Priority/ordering - More specific mocks should come first
- Headers required - Some mocks require specific headers
Debug Steps
Section titled “Debug Steps”# Check what mocks are loadedmockd list
# View request logs to see what's being receivedmockd logs
# Use doctor to diagnose issuesmockd doctorChecklist
Section titled “Checklist”- Verify the HTTP method matches exactly (case-sensitive)
- Check for trailing slashes in paths (
/api/usersvs/api/users/) - Confirm the mock file has
enabled: trueor the field is omitted (defaults to true) - Review mock priority if you have overlapping patterns
- Check if the mock requires specific headers that aren’t being sent
Port Already in Use
Section titled “Port Already in Use”If mockd fails to start with a “port already in use” error:
# Check what's using the port (macOS/Linux)lsof -i :4280
# Check what's using the port (Windows)netstat -ano | findstr :4280
# Use a different portmockd start --port 3000Solutions
Section titled “Solutions”- Kill the existing process using the port
- Choose a different port with the
--portflag - Check if another mockd instance is already running
Server Won’t Start
Section titled “Server Won’t Start”If the server fails to start:
- Check config file syntax with
mockd config validate - Run
mockd doctorfor diagnostics - Check permissions on data directory
- Verify mock files are valid YAML/JSON
Common Causes
Section titled “Common Causes”| Issue | Solution |
|---|---|
| Invalid YAML syntax | Use a YAML linter to validate files |
| Missing required fields | Check mock schema requirements |
| Permission denied | Ensure write access to data directory |
| Invalid port number | Use a port between 1024-65535 |
gRPC Issues
Section titled “gRPC Issues”When working with gRPC mocks:
- Proto files must be valid and parseable
- Reflection must be enabled for grpcurl to work
- Service and method names are case-sensitive
- Check that proto import paths are correct
Debugging gRPC
Section titled “Debugging gRPC”# Test gRPC reflectiongrpcurl -plaintext localhost:4280 list
# Check specific service methodsgrpcurl -plaintext localhost:4280 describe your.service.NameWebSocket Issues
Section titled “WebSocket Issues”For WebSocket connection problems:
- Check subprotocol matching between client and mock
- Verify upgrade headers are correct
- Ensure the WebSocket path matches the mock configuration
- Check for proxy/firewall issues that may block WebSocket upgrades
WebSocket Debugging Tips
Section titled “WebSocket Debugging Tips”- Use browser DevTools Network tab to inspect WebSocket handshake
- Check the
Sec-WebSocket-Protocolheader if using subprotocols - Verify the connection URL scheme (
ws://vswss://)
Performance Issues
Section titled “Performance Issues”If mockd is running slowly:
- Check mock count (large lists slow down matching)
- Enable metrics endpoint for monitoring
- Consider using more specific matchers
- Review regex patterns for efficiency
Performance Optimization
Section titled “Performance Optimization”# Check current mock countmockd list | wc -l
# Enable metrics for monitoringmockd start --metrics
# View performance metricscurl http://localhost:4280/__mockd/metricsBest Practices
Section titled “Best Practices”- Use exact path matching when possible instead of regex
- Group related mocks into separate files
- Remove unused or disabled mocks
- Use path parameters instead of regex for dynamic segments
Getting Help
Section titled “Getting Help”If you’re still experiencing issues:
- Run
mockd doctorfor a comprehensive diagnostic report - Check the logs with
mockd logs --level debug - Search existing issues on GitHub
- Open a new issue with diagnostic output and reproduction steps