This guide explains how to migrate from Weaviate client v3 to v4.17.0 and upgrade your Weaviate server from version 1.19.0 to 1.27.0 or higher. This migration is required for Dify versions that include the weaviate-client v4 upgrade.
Overview
Starting with an upcoming Dify release, the weaviate-client has been upgraded from v3 to v4.17.0. This upgrade brings significant performance improvements and better stability, but requires Weaviate server version 1.27.0 or higher.Who Is Affected?
This migration affects:- Self-hosted Dify users running their own Weaviate instances on versions below 1.27.0
- Users currently on Weaviate server version 1.19.0-1.26.x
- Users upgrading to Dify versions with weaviate-client v4
- Cloud-hosted Weaviate users (Weaviate Cloud manages the server version)
- Users already on Weaviate 1.27.0+ can upgrade Dify without additional steps
- Users running Dify’s default Docker Compose setup (Weaviate version is updated automatically)
Breaking Changes
Client v4 Requirements
The weaviate-client v4 introduces several breaking changes:- Minimum Server Version: Requires Weaviate server 1.27.0 or higher
- API Changes: New import structure (
weaviate.classesinstead ofweaviate.client) - gRPC Support: Uses gRPC by default on port 50051 for improved performance
- Authentication Changes: Updated authentication methods and configuration
Why Upgrade?
- Performance: Significantly faster query and import operations via gRPC (50051)
- Stability: Better connection handling and error recovery
- Future Compatibility: Access to latest Weaviate features and ongoing support
- Security: Weaviate 1.19.0 is over a year old and no longer receives security updates
Version Compatibility Matrix
| Dify Version | weaviate-client Version | Compatible Weaviate Server Versions |
|---|---|---|
| ≤ 1.9.1 | v3.x | 1.19.0 - 1.26.x |
| ≥ 1.9.2* | v4.17.0 | 1.27.0+ (tested up to 1.32.11) |
*The exact Dify version with weaviate-client v4 may vary. Check the release notes for your specific version. This migration applies to any Dify version using weaviate-client v4.17.0 or higher.
Weaviate server version 1.19.0 was released over a year ago and is now outdated. Upgrading to 1.27.0+ provides access to numerous improvements in performance, stability, and features.
Prerequisites
Before starting the migration, complete these steps:-
Check Your Current Weaviate Version
Look for the
versionfield in the response. -
Backup Your Data
- Create a complete backup of your Weaviate data
- Backup your Docker volumes if using Docker Compose
- Document your current configuration settings
-
Review System Requirements
- Ensure sufficient disk space for database migration
- Verify network connectivity between Dify and Weaviate
- Confirm gRPC port (50051) is accessible if using external Weaviate
-
Plan Downtime
- The migration will require service downtime
- Notify users if running in production
- Schedule migration during low-traffic periods
Migration Paths
Choose the migration path that matches your deployment setup:Path A: Docker Compose Users (Recommended)
This is the simplest path for users running Dify via Docker Compose with the bundled Weaviate instance.If you’re using Dify’s standard Docker Compose setup, the Weaviate version is automatically updated when you upgrade Dify. No manual configuration is required.
Step 1: Backup Your Data
Navigate to your Dify project directory and backup your Docker volumes:Store the backup file in a safe location outside the project directory. You’ll need it if the migration fails and you need to rollback.
Step 2: Update Dify
Pull the latest Dify version that includes weaviate-client v4 and Weaviate 1.27.0+:- Weaviate server 1.27.0+ image
- weaviate-client v4.17.0 (installed automatically in Dify containers)
- Proper gRPC port configuration (50051)
Step 3: Monitor Startup
Watch the logs to ensure services start correctly:Step 4: Verify Migration
See the Verification Steps section below.Path B: External/Self-Hosted Weaviate
For users running Weaviate on a separate server, managed instance, or Weaviate Cloud.Step 1: Backup Weaviate Data
Use Weaviate’s backup API to create a complete backup:For detailed backup instructions, refer to the Weaviate backup documentation.
Step 2: Stop Your Weaviate Instance
Step 3: Upgrade Weaviate Server
For Docker:Step 4: Verify Weaviate Upgrade
Check that Weaviate is running the correct version:Step 5: Update Dify Configuration
Update your Dify environment variables to configure the external Weaviate connection:The
WEAVIATE_GRPC_ENDPOINT should be in the format hostname:port without any protocol prefix (no grpc:// or http://).Step 6: Update Dify
Step 7: Verify Migration
See the Verification Steps section below.Data Migration for Legacy Versions
Automatic Migration
In most cases, Weaviate 1.27.0 will automatically migrate data from 1.19.0:- Stop Weaviate 1.19.0
- Start Weaviate 1.27.0 with the same data directory
- Weaviate will detect the old format and migrate automatically
- Monitor logs for migration progress and any errors
Manual Migration (If Automatic Fails)
If automatic migration fails, use Weaviate’s export/import tools:1. Export Data from Old Version
Use the Cursor API or backup feature to export all data. For large datasets, use Weaviate’s backup API:2. Import Data to New Version
After upgrading to Weaviate 1.27.0, restore the backup:For comprehensive migration guidance, especially for complex schemas or large datasets, refer to the official Weaviate Migration Guide.
Configuration Changes
New Environment Variables
The following new environment variable is available in Dify versions with weaviate-client v4:WEAVIATE_GRPC_ENDPOINT
Description: Specifies the gRPC endpoint for Weaviate connections. Using gRPC significantly improves performance for batch operations and queries. Format:hostname:port (NO protocol prefix)
Default Ports:
- Insecure: 50051
- Secure (TLS): 443
Updated Environment Variables
All existing Weaviate environment variables remain the same:- WEAVIATE_ENDPOINT: HTTP endpoint for Weaviate (e.g.,
http://weaviate:8080) - WEAVIATE_API_KEY: API key for authentication (if enabled)
- WEAVIATE_BATCH_SIZE: Batch size for imports (default: 100)
- WEAVIATE_GRPC_ENABLED: Enable/disable gRPC (default: true in v4)
Complete Configuration Example
Verification Steps
After completing the migration, verify everything is working correctly:1. Check Weaviate Connection
Verify Weaviate is accessible and running the correct version:2. Verify Dify Connection
Check the Dify logs for successful Weaviate connection:3. Test Knowledge Base Creation
- Log into your Dify instance
- Navigate to Knowledge Base section
- Create a new knowledge base
- Upload a test document (PDF, TXT, or MD)
- Wait for indexing to complete
- Check that status changes from “QUEUING” → “INDEXING” → “AVAILABLE”
If documents get stuck in “QUEUING” status, check that the Celery worker is running:
docker compose logs worker4. Test Vector Search
- Create or open a chat application with knowledge base integration
- Ask a question that should retrieve information from your knowledge base
- Verify that relevant results are returned with correct scores
- Check the citation/source links work correctly
5. Verify gRPC Performance
If gRPC is enabled, you should see improved performance:With gRPC properly configured, vector search queries should be 2-5x faster compared to HTTP-only connections.
Troubleshooting
Issue: “No module named ‘weaviate.classes’”
Cause: The weaviate-client v4 is not installed, or v3 is still being used. Solution:Issue: Connection Refused on gRPC Port (50051)
Cause: Port 50051 is not exposed, not accessible, or Weaviate is not listening on it. Solution:- For Docker Compose users with bundled Weaviate: The port is available internally between containers. No action needed unless you’re connecting from outside Docker.
-
For external Weaviate:
-
Check firewall rules:
Issue: Authentication Errors (401 Unauthorized)
Cause: API key mismatch or authentication configuration issue. Solution:-
Verify API key matches in both Weaviate and Dify:
-
If using anonymous access:
Then remove
WEAVIATE_API_KEYfrom Dify configuration.
Issue: Documents Stuck in “QUEUING” Status
Cause: Celery worker not running or not connected to Redis. Solution:Issue: Slow Performance After Migration
Cause: gRPC not enabled or configured incorrectly. Solution:-
Verify gRPC configuration:
Should show:
-
Test gRPC connectivity:
- If still slow, check network latency between Dify and Weaviate
Issue: Schema Migration Errors
Cause: Incompatible schema changes between Weaviate versions or corrupted data. Solution:-
Check Weaviate logs for specific error messages:
-
List current schema:
-
If necessary, delete corrupted collections (⚠️ this deletes all data):
-
Restart Dify to recreate schema:
Issue: Docker Volume Permission Errors
Cause: User ID mismatch in Docker containers. Solution:Rollback Plan
If the migration fails and you need to rollback:Step 1: Stop Services
Step 2: Restore Backup
Step 3: Revert Dify Version
Step 4: Restart Services
Step 5: Verify Rollback
Check that services are running with old versions:Always test the rollback procedure in a staging environment first if possible. Maintain multiple backup copies before attempting major migrations.
Additional Resources
Official Documentation
- Weaviate Migration Guide
- Weaviate v4 Client Documentation
- Weaviate Backup and Restore
- Dify Self-Hosting Guide
- Dify Environment Variables
Community Resources
- Dify GitHub Repository
- Dify GitHub Issues - Weaviate
- Weaviate Community Forum
- Dify Discord Community
Migration Tools
Summary
This migration brings important improvements to Dify’s vector storage capabilities: Better Performance: gRPC support dramatically improves query and import speeds (2-5x faster) Improved Stability: Enhanced connection handling and error recovery Security: Access to security updates and patches not available in Weaviate 1.19.0 Future-Proof: Access to latest Weaviate features and ongoing support While this is a breaking change requiring server upgrade for users on old versions, the benefits significantly outweigh the migration effort. Most Docker Compose users can complete the migration in under 15 minutes with the automatic update.If you encounter any issues not covered in this guide, please report them on the Dify GitHub Issues page with the label “weaviate” and “migration”.