Can't start Laravel, I get "Base table or view not found" error
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Can't Start Laravel, I Get "Base table or view not found" Error: A Developer's Guide to Migration Chaos
As a senior developer working with Laravel, dealing with database schema issues can be incredibly frustrating. One of the most common sticking points is encountering errors like SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exercise1.categories' doesn't exist, especially after performing migration rollbacks. This error signals a mismatch between what your application expects to find in the database and what actually exists, halting the entire startup process.
This post will diagnose why this happens and provide a robust, step-by-step solution to restore your Laravel application's database structure without losing data (if possible).
Understanding the Migration Dilemma
The error you are facing stems directly from the lifecycle of Laravel migrations. When you use php artisan migrate, Laravel tracks which migrations have been executed by recording them in a special table in your database (usually migrations).
When you execute php artisan migrate:rollback, Laravel executes the down() methods defined in those migration files, effectively undoing the schema changes (like dropping tables). If you then try to run php artisan serve without running migrations again, the application attempts to query for tables (categories, articles) that were explicitly dropped during the rollback, leading directly to the "table not found" error.
The core issue is: Your database schema does not match the state defined by your current migration files.
The Solution: Rebuilding the Schema Correctly
Since you have rolled back migrations, the most reliable way to fix this is to tell Laravel to re-apply the necessary structure based on your current set of migration files. We need to force the database to execute the up() methods for those migrations that should exist.
Here is the recommended sequence of steps to resolve this frustrating problem:
Step 1: Verify Migration State (Optional but Recommended)
Before blindly running commands, it's good practice to look at your migration history. You can check the status using:
php artisan migrate:status
This command will show you exactly which migrations have been run and which are pending. This step helps confirm that the rollback process left the state exactly where you intended.
Step 2: Re-run Migrations
Since the tables were dropped via the rollback, you need to re-execute the migration sequence to recreate the necessary tables. Since your goal is to restore the structure defined by the files, running a fresh migration command should work perfectly.
Execute the following command to rebuild the schema from scratch based on your existing migration files:
php artisan migrate
If you are working with a fresh development database (like SQLite or a clean MySQL instance), this command will execute both CreateCategoriesTable and CreateArticlesTable, successfully recreating the missing tables.
Note: If you were dealing with production data that should have been preserved, rolling back and rerunning migrations is destructive. In such high-stakes scenarios, a backup restore procedure should always be prioritized over direct migration manipulation. For development environments, however, this method is the fastest fix.
Best Practices for Migration Management
To prevent this type of error from recurring, adopt these best practices when managing database changes in Laravel:
- Use Separate Environments: Always manage your migrations within clearly defined environments (local development vs. staging vs. production). Never perform structural changes directly on a live production database without strict oversight.
- Understand Rollbacks: Be acutely aware of what
migrate:rollbackdoes. It undoes the forward steps. If you need to keep data, consider using manual SQL dumps or version control to manage schema history outside of simple rollbacks. - Version Control is Key: Ensure all your migration files are committed to Git. This provides an undeniable history that allows you to revert complex changes safely if necessary. As a reminder, maintaining clean code structure and robust data management is central to building scalable applications on Laravel, as emphasized by the principles behind frameworks like laravelcompany.com.
Conclusion
The "Base table or view not found" error after migration rollbacks is a common symptom of trying to operate on a database state that has been intentionally altered. By understanding how Laravel manages its schema through migrations and simply instructing it to re-run the necessary commands (php artisan migrate), you can quickly resolve this issue. Always approach schema changes with caution, utilize version control, and follow these best practices to ensure your development workflow remains smooth and predictable.