Migrating a website to a new VPS can improve control, performance, and flexibility, but problems can sometimes appear immediately after the move. A website that worked perfectly on the old server may suddenly show a 404 error, permission denied message, or database connection error.
These issues are usually caused by differences in server configuration, file ownership, application settings, or DNS and web-server configuration.
If you recently migrate website to VPS and something is not working as expected, don't panic. Most post-migration problems can be traced back to a few common configuration areas.
This guide explains the most common VPS migration errors and simple ways to troubleshoot them.
1. Website Shows a 404 Error After Migration
A 404 error means the requested page or resource cannot be found.
After moving a website to a VPS, a 404 error can happen even when the website files are present.
Common causes include:
Incorrect document root
Missing
.htaccessfileIncorrect Apache or Nginx configuration
Laravel routing not configured correctly
Wrong domain configuration
Missing application files
Incorrect URL or rewrite rules
Check the Document Root
First, confirm that your domain is pointing to the correct website directory.
For example, if your application files are stored in:
/var/www/example.com
the web server should be configured to use the correct directory as its document root.
For Laravel applications, the web root is normally the public directory rather than the project root.
Using the wrong directory can result in missing pages or exposed application files.
Check .htaccess
If you are using Apache, check whether the .htaccess file was transferred during the migration.
Laravel and many custom PHP applications rely on rewrite rules to send requests to the correct application entry point.
If .htaccess exists but routing still fails, check whether Apache's rewrite functionality and the relevant directory configuration allow the required rules.
This is an important step when you need to fix htaccess VPS problems after migration.
2. Permission Denied Errors
Another common problem after moving a website is a permission error.
You may see messages such as:
Permission denied
or the application may fail when trying to create, upload, modify, or write a file.
This usually happens because the files were copied with ownership or permissions that do not match the new server's web-server user.
Check File Ownership
The web server needs appropriate access to the directories used by the application.
For example, a PHP or Laravel application may need write access to specific storage, cache, or log directories.
Do not simply give full permissions to the entire website directory.
Instead, identify which directories actually need write access and configure their ownership and permissions accordingly.
Check With the Web Server User
Apache and Nginx/PHP-FPM may run under different users depending on the Linux distribution and server configuration.
Find out which user is running your web service and make sure the required application directories are accessible to that user.
This is safer than applying a blanket chmod 777 permission.
Using excessive permissions may make troubleshooting appear easier, but it can create unnecessary security risks.
3. Error Establishing Database Connection
A database connection error is another common issue after migration.
The website files may load correctly, but the application cannot retrieve information from MySQL or MariaDB.
Common causes include:
Incorrect database name
Incorrect database username
Incorrect password
Wrong database host
Database user not assigned to the database
Database server not running
Incorrect environment variables
Firewall or network configuration
Check Database Credentials
Start by checking the application's database configuration.
For a Laravel application, review the environment configuration and verify the database name, username, password, host, and port.
For a custom PHP application, check the database configuration file used by the project.
Make sure these values match the database and user created on the new VPS.
Check Database User Permissions
Creating a database is not enough. The database user must also have the required permissions.
Confirm that the correct user is associated with the correct database.
Also check whether the database service is running on the new VPS.
A simple configuration mistake can produce an error establishing database connection VPS users commonly encounter after migration.
4. Check PHP and Application Versions
Sometimes the migration itself is successful, but the application fails because the new VPS uses a different software version.
For example, the old server may have been running one PHP version while the new server uses another.
Check:
PHP version
Required PHP extensions
Composer version
Laravel version
MySQL/MariaDB version
Node.js version if required
If a required PHP extension is missing, application features may fail even though the main website loads.
For Laravel applications, compare the new server environment with the application's documented requirements.
5. Check DNS and Domain Configuration
If the website is not opening correctly after migration, verify that the domain is actually pointing to the new VPS.
Check the domain's A record and, if applicable, its AAAA record.
An old DNS record can send some visitors to the previous server.
You should also confirm that the domain is configured correctly in Apache or Nginx.
If the DNS points to the new server but the web server is configured for a different domain or document root, the expected website may still not appear.
6. Check SSL After Migration
HTTPS configuration should also be tested after moving to a new VPS.
A website may work over HTTP but show an SSL error when accessed through HTTPS.
Check that:
The SSL certificate is installed on the new VPS
The certificate covers the correct domain
Apache or Nginx is using the correct certificate
HTTP-to-HTTPS redirects work correctly
The application URL uses HTTPS where required
Do not assume that the SSL configuration from the old server automatically exists on the new one.
7. Use Logs Instead of Guessing
When troubleshooting VPS migration problems, server and application logs can save a lot of time.
Check the relevant:
Apache or Nginx error logs
PHP error logs
Laravel application logs
Database logs
Node.js application logs
The exact log location depends on your Linux distribution and software configuration.
Instead of repeatedly changing settings, look at the error message first. It often points directly toward the problem.
8. Test One Problem at a Time
When troubleshooting a newly migrated website, avoid changing multiple configurations at once.
For example, if you have a 404 error, first check the document root and rewrite configuration.
If you have a database error, check the database credentials and service.
If you have a permission error, check ownership and directory permissions.
Making several unrelated changes simultaneously can make it difficult to determine which change actually fixed the problem.
Post-Migration Troubleshooting Checklist
After you migrate website to VPS, use this checklist if something goes wrong:
Check the domain's DNS records
Confirm the correct document root
Check
.htaccessand rewrite rulesVerify PHP and required extensions
Check file ownership
Review directory permissions
Verify database credentials
Confirm database user permissions
Check that MySQL/MariaDB is running
Verify environment variables
Check SSL configuration
Review server and application logs
Test the website again after each change
Conclusion
Post-migration VPS problems are common, but they are usually configuration issues rather than signs that the migration has failed.
A 404 error may point to the wrong document root or rewrite configuration. Permission errors are often related to file ownership and access settings, while database connection errors usually involve credentials, users, or the database service.
If you are planning a migration and want to understand the process before troubleshooting, read our previous guide: How to Migrate a Custom PHP or Laravel Application to a New Linux VPS.
The key is to troubleshoot systematically: check the configuration, review the logs, fix one issue at a time, and test again. This makes it much easier to get your application running normally on the new VPS.