Troubleshooting
This guide covers common issues and their solutions when working with Unchained Engine.
Quick Diagnostics
Check Server Health
# Test API endpoint
curl http://localhost:4010/graphql \
-H "Content-Type: application/json" \
-d '{"query":"{ __typename }"}'
# Expected response
{"data":{"__typename":"Query"}}
Check Logs
# Development
npm run dev # Watch console output
# Production (Docker)
docker logs -f my-shop
# Production (PM2)
pm2 logs
Check MongoDB Connection
# Test connection
mongosh "mongodb://localhost:27017/unchained" --eval "db.adminCommand('ping')"
# Check collections
mongosh "mongodb://localhost:27017/unchained" --eval "db.getCollectionNames()"
Common Issues
Server Won't Start
Port Already in Use
Error: listen EADDRINUSE: address already in use :::4010
Solution:
# Find process using port
lsof -i :4010
# Kill the process
kill -9 <PID>
# Or use a different port
PORT=4011 npm run dev
MongoDB Connection Failed
MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
Solutions:
- Start MongoDB:
# macOS with Homebrew
brew services start mongodb-community
# Docker
docker run -d -p 27017:27017 mongo:7
- Check connection string in
.env:
MONGO_URL=mongodb://localhost:27017/unchained
- For MongoDB Atlas, ensure IP whitelist includes your IP
Missing Environment Variables
Error: UNCHAINED_TOKEN_SECRET is required
Solution:
Create .env file with required variables:
UNCHAINED_TOKEN_SECRET=your-secret-at-least-32-characters
ROOT_URL=http://localhost:4010
Authentication Issues
"Unauthorized" Error
{"errors":[{"message":"Unauthorized"}]}
Solutions:
- Ensure Authorization header is set:
Authorization: Bearer <your-token>
- Check token hasn't expired
- Verify token secret matches between requests
Guest Login Fails
Solutions:
- Check user module is properly initialized
- Verify database is writable
- Check for validation errors in logs
Cart and Checkout
"No Cart" / Cart is Empty
Solutions:
- Ensure user is authenticated:
mutation LoginAsGuest {
loginAsGuest {
_id
tokenExpires
}
}
- Use the token in subsequent requests
- Check cart was created:
query {
me {
cart {
_id
}
}
}
Checkout Fails
Error: No delivery provider set
Solutions:
- Create delivery provider in Admin UI
- Set delivery provider before checkout:
mutation SetDeliveryProvider {
updateCart(deliveryProviderId: "...") {
_id
}
}
- Verify provider is active
Payment Not Processing
Solutions:
- Check payment provider configuration
- Verify API keys are correct (not test keys in production)
- Check webhook is configured
- Look for errors in payment provider dashboard
Products
Product Not Visible
Solutions:
- Check product status is "Active":
query {
product(productId: "...") {
status
}
}
- Ensure product has at least one price:
query ProductWithPrice {
product(productId: "...") {
... on SimpleProduct {
simulatedPrice(currencyCode: "CHF") {
amount
currencyCode
}
}
}
}
- Verify product is assigned to an assortment (if filtering by category)
Price Not Showing
Solutions:
- Check price exists for the currency:
mutation UpdateProductPricing {
updateProductCommerce(productId: "...", commerce: {
pricing: [{
currencyCode: "CHF"
countryCode: "CH"
amount: 4900
isTaxable: true
isNetPrice: true
}]
}) {
_id
}
}
- Verify currency is active
- Check pricing adapters aren't filtering it out
Admin UI
Can't Access Admin UI
Solutions:
- Verify engine is running on correct port
- Check CORS settings allow Admin UI origin
- Clear browser cache/cookies
Login Not Working
Solutions:
- Reset admin password via CLI or database
- Check email verification isn't required
- Verify user has admin role
File Uploads
Upload Fails
Solutions:
- Ensure a file storage plugin is imported in your entry file:
// GridFS (MongoDB built-in)
import '@unchainedshop/plugins/files/gridfs';
// Or MinIO/S3
import '@unchainedshop/plugins/files/minio';
- For MinIO/S3, verify credentials:
MINIO_ENDPOINT=...
MINIO_ACCESS_KEY=...
MINIO_SECRET_KEY=...
MINIO_BUCKET=...
- Check file size limits
Images Not Loading
Solutions:
- Verify file URLs are accessible
- Check CORS headers on storage
- For signed URLs, ensure signature is valid
Performance Issues
Slow Queries
Unchained Engine automatically creates indexes on commonly queried fields during startup. Adding custom indexes is only necessary when you've added custom fields to your schemas.
Solutions:
- Add indexes for custom fields:
// Only needed if you query by custom fields
await db.collection('products').createIndex({ 'meta.customField': 1 });
- Check for N+1 queries in resolvers
- Enable query logging to identify slow queries
Memory Issues
Solutions:
- Increase Node.js memory:
NODE_OPTIONS="--max-old-space-size=4096" npm start
- Check for memory leaks
- Monitor with:
node --inspect lib/index.js
Email Issues
Emails Not Sending
Solutions:
- Check MAIL_URL is configured:
MAIL_URL=smtp://user:pass@smtp.example.com:587
- Verify SMTP credentials
- Check spam folder
- Test with email preview (development only)
Email Template Errors
Solutions:
- Check template syntax
- Verify all required variables are passed
- Look for errors in worker logs
Debug Mode
Enable verbose logging:
# Enable debug logging
DEBUG=unchained:* npm run dev
# Specific modules
DEBUG=unchained:core:* npm run dev
DEBUG=unchained:api:* npm run dev
Getting Help
Before Asking for Help
- Check this troubleshooting guide
- Search GitHub Issues
- Review GitHub Discussions
Providing Information
When reporting issues, include:
-
Environment:
- Node.js version (
node --version) - Unchained version (
npm list @unchainedshop/platform) - Operating system
- Node.js version (
-
Error message: Full error with stack trace
-
Steps to reproduce: Minimal example
-
Relevant configuration: (sanitize secrets)
-
Logs: Recent log output
Example Issue Report
## Environment
- Node.js: 22.0.0
- Unchained: 3.0.0
- OS: macOS 14.0
## Description
Checkout fails with "Payment provider not found" error
## Steps to Reproduce
1. Create cart
2. Add product
3. Set delivery provider
4. Call checkoutCart
## Error
```
Error: Payment provider not found for order xyz
at PaymentDirector.resolve (...)
```
## Configuration
```typescript
await startPlatform({
// ... config
});
```
## Expected Behavior
Checkout should complete using default payment provider
Related Documentation
- FAQ - Frequently asked questions