Troubleshooting Guide
This guide covers common issues you may encounter when using mockd and how to resolve them.
Quick Diagnostics
Section titled “Quick Diagnostics”Before diving into specific issues, run these commands:
# Full diagnostic reportmockd doctor
# Check server healthmockd health
# Show what's runningmockd status
# List loaded mocksmockd list
# View recent request logsmockd logs --requests -n 10Mock 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
# Show full IDs and paths without truncationmockd list --no-truncate
# View request logs to see what's being receivedmockd logs --requests
# Delete a problematic mock by pathmockd delete --path /api/users --method GET
# 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
# Check all mockd default portsmockd ports
# Use a different portmockd serve --port 3000Default Ports
Section titled “Default Ports”| Port | Service | Override Flag |
|---|---|---|
| 4280 | Mock server (HTTP, GraphQL, WebSocket, SOAP, SSE) | --port |
| 4290 | Admin API | --admin-port |
| 50051 | gRPC (configurable per mock) | In YAML config |
| 1883 | MQTT (configurable per mock) | In YAML config |
Solutions
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:
mockd ps - Stop a running instance:
mockd stop
Server Won’t Start
Section titled “Server Won’t Start”If the server fails to start:
- Check config file syntax with
mockd validate mockd.yaml - 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 | Run mockd validate mockd.yaml |
| Missing required fields | Check mock schema requirements |
| Permission denied | Ensure write access to data directory |
| Invalid port number | Use a port between 1024-65535 |
| Proto file not found | Check protoFile path is relative to config |
HTTP Issues
Section titled “HTTP Issues”Response Body Not Matching Expected
Section titled “Response Body Not Matching Expected”# Check the exact mock configurationmockd get <mock-id> --json
# Check request logs for what was actually matchedmockd logs --requests -n 5Wrong Mock Matched
Section titled “Wrong Mock Matched”When multiple mocks could match, priority matters:
- Mocks with more specific paths win (
/api/users/1>/api/users/{id}) - Mocks with more matchers win (path + headers > path only)
- Earlier mocks in config win if priority is equal
# List all mocks and their pathsmockd list --no-truncateRequest Body Matching Not Working
Section titled “Request Body Matching Not Working”- Ensure
Content-Typeheader is sent with the request - JSON body matching requires valid JSON in both request and matcher
- Check for extra whitespace or field ordering differences
GraphQL Issues
Section titled “GraphQL Issues”Query Returns Empty Data
Section titled “Query Returns Empty Data”- Verify the operation name matches a resolver in your config
- Check that the schema defines the query type you’re calling
- Ensure introspection is enabled if your client requires it
# Test a GraphQL query directlycurl -X POST http://localhost:4280/graphql \ -H "Content-Type: application/json" \ -d '{"query": "{ users { id name } }"}'
# Check introspectioncurl -X POST http://localhost:4280/graphql \ -H "Content-Type: application/json" \ -d '{"query": "{ __schema { types { name } } }"}'Schema Validation Errors
Section titled “Schema Validation Errors”# Validate a schema filemockd graphql validate schema.graphqlResolver Not Found
Section titled “Resolver Not Found”- Resolver keys must be
Type.fieldformat:Query.users,Mutation.createUser - Field names are case-sensitive
- Check that the schema defines the operation you’re resolving
gRPC Issues
Section titled “gRPC Issues”Proto File Errors
Section titled “Proto File Errors”- Proto files must be valid protobuf syntax
- Check import paths if your proto references other files
- Verify the package name matches your service configuration
# List services from a proto filemockd grpc list api.proto
# Verify gRPC server is runninggrpcurl -plaintext localhost:50051 list”Service not found” Errors
Section titled “”Service not found” Errors”- Service names must be fully qualified:
package.ServiceName(e.g.,users.UserService) - Method names are case-sensitive
- Check that the proto file path is correct relative to your config file
Reflection Not Working
Section titled “Reflection Not Working”# Test gRPC reflectiongrpcurl -plaintext localhost:50051 list
# If reflection is disabled, use the proto file directlygrpcurl -plaintext -proto ./service.proto \ localhost:50051 package.Service/MethodEnsure reflection: true is set in your gRPC config.
Port Conflicts Between gRPC Mocks
Section titled “Port Conflicts Between gRPC Mocks”Multiple gRPC mocks on the same port are automatically merged. If you see conflicts:
# Check which mocks are on port 50051mockd list --type grpcWebSocket Issues
Section titled “WebSocket Issues”Connection Refused
Section titled “Connection Refused”- Verify the WebSocket path matches your mock:
/wsvs/ws/chat - Ensure you’re using the correct scheme:
ws://(nothttp://) - Check that mockd is running on the expected port
# Test WebSocket endpoint existscurl -i http://localhost:4280/ws
# Connect with mockd CLImockd websocket connect ws://localhost:4280/wsSubprotocol Mismatch
Section titled “Subprotocol Mismatch”If your client requires a specific subprotocol:
websocket: path: /ws subprotocols: - chat.v1 requireSubprotocol: true # Rejects connections without matching subprotocolCheck the Sec-WebSocket-Protocol header in your client connection.
Messages Not Matching
Section titled “Messages Not Matching”- Matchers are evaluated in order — first match wins
- Check
matchType:exact,contains,prefix,regex,json - For JSON matching, verify the JSONPath expression is correct
Connection Drops
Section titled “Connection Drops”- Enable heartbeat/keepalive in your WebSocket mock config
- Check
idleTimeout— connections are closed after inactivity - Some proxies/firewalls drop idle WebSocket connections
websocket: heartbeat: enabled: true interval: "30s" timeout: "10s"MQTT Issues
Section titled “MQTT Issues”Can’t Connect to Broker
Section titled “Can’t Connect to Broker”- Default MQTT port is 1883 (not 4280)
- Check if authentication is required
# Test connection with mosquittomosquitto_sub -h localhost -p 1883 -t "test/#" -v
# With authenticationmosquitto_sub -h localhost -p 1883 -u user -P pass -t "test/#"Not Receiving Messages
Section titled “Not Receiving Messages”- Check topic name spelling and wildcards (
+for single level,#for multi-level) - Verify QoS level — QoS 0 messages may be lost
- Check if retained messages are configured
# Subscribe to all topicsmockd mqtt subscribe "#"
# Subscribe with specific QoSmockd mqtt subscribe --qos 1 "sensors/#"Authentication Denied
Section titled “Authentication Denied”- Verify username/password match the
auth.usersconfig - Check ACL rules — the user may not have access to the requested topic
- ACL access levels:
read,write,readwrite/all
SOAP Issues
Section titled “SOAP Issues””No Operation Matched”
Section titled “”No Operation Matched””- Verify the
SOAPActionheader matches the configuredsoapActionvalue - SOAPAction matching is exact (case-sensitive)
# Include the SOAPAction headercurl -X POST http://localhost:4280/soap/UserService \ -H "Content-Type: text/xml" \ -H "SOAPAction: http://example.com/GetUser" \ -d @request.xmlWSDL Not Serving
Section titled “WSDL Not Serving”- Access the WSDL by appending
?wsdlto the endpoint URL - Check that the
wsdlorwsdlFilefield is set in your config
curl http://localhost:4280/soap/UserService?wsdlXPath Matching Not Working
Section titled “XPath Matching Not Working”- XPath expressions are evaluated against the SOAP body (inside
<soap:Body>) - Use
//Element/text()to match element text content - Namespace prefixes in XPath may need to match the request
SSE Issues
Section titled “SSE Issues”Stream Ends Immediately
Section titled “Stream Ends Immediately”- Check the
lifecycle.maxEventssetting — it may be too low - Verify
lifecycle.timeoutis long enough for your use case - Ensure your client sends
Accept: text/event-stream
# Test SSE connectioncurl -N -H "Accept: text/event-stream" http://localhost:4280/eventsEvents Not Repeating
Section titled “Events Not Repeating”- Set
timing.repeator configure lifecycle for continuous streams - Check if
maxEventsis limiting the number of events sent
OpenAI Template Issues
Section titled “OpenAI Template Issues”- The
openai-chattemplate expectsPOSTmethod - Verify
templateParams.tokensis an array of strings - Check that
includeDone: trueis set if your client expects[DONE]
Performance Issues
Section titled “Performance Issues”If mockd is running slowly:
- Check mock count (large lists slow down matching)
- Consider using more specific matchers
- Review regex patterns for efficiency
Performance Optimization
Section titled “Performance Optimization”# Check current mock count and statusmockd status
# Show all ports in usemockd portsBest 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 (
{id}) 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 - Search existing issues on GitHub
- Open a new issue with diagnostic output and reproduction steps
Include this information when reporting issues:
mockd versionmockd doctormockd status --json