Custom Post Type 404 Error even after flushing rewrite rules

Your code is working perfectly. You have to refresh/flush permalinks after creating “Custom Post Type” hook.

Step 1: In the main menu find “Settings > Permalinks”.
Step 2: Scroll down if needed and click “Save Changes”.
Step 3: Rewrite rules and permalinks are flushed.