How To Fix Blank Admin Page Issue in Magento 2?

Today, we’re going to teach you guys how to fix blank admin page issue in your Magento 2 store.

The Magento 2 blank admin page issue usually occurs either when you’re upgrading your existing store to the latest Magento 2 version or even when you’re installing Magento 2 for the first time in localhost.

If you’ve encountered this issue, you might be seeing something like the below screenshot:

Fix Blank Admin Page Issue Magento 2

However, the proper screen of the Magento 2 admin page should be like this:

Fix Blank Admin Page Issue

Cause of the Issue

The blank admin page issue in Magento 2 usually occurs when Magento 2 and Windows have different file path indicators.

For example, if the path on your Windows is like this: C://Magento2/App/Code, while the path in Magento 2 code is like this: Magento2\App\Code, then it immediately causes the blank admin page issue in Magento 2.

Solution

The Magento 2 blank admin page issue generally occurs in Magento 2.3.x & Magento 2.2.7 versions.

But, since both Magento 2.3.x & Magento 2.2.7 have some code differences, the solutions to solve the blank admin page issues are also different.

  • Solution for Magento 2.3.x Version

Step - 1

First of all, open the Validator.php file from the C:\\xampp\htdocs\magento2_installation_folder\vendor\magento\framework\View\Element\Template\File\ folder.

If you can’t find the \vendor\magento\framework\ folder path, look for the Validator.php file in the C:\xampp\htdocs\magento\lib\internal\Magento\Framework\View\Element\Template\File\Validator.php folder.

Step - 2

After that, scroll down to line 138 or 139 in the Validator.php file and you’ll see a code like below:

$realPath = $this->fileDriver->getRealPath($path);

Fix Blank Admin Page Issue Magento

The highlighted code in the above screenshot is responsible for defining the admin template file path. And we need to update this line of code in order to fix the blank admin page issue.

Replace the highlighted code with the following:

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

Step - 3

Now, save the file and refresh the Magento 2 admin page to find out if the issue is solved or not.

Fix Blank Admin Page Issue Magento 2

  • Solution for Magento 2.2.7 Version

The solution to fix the blank admin page issue is a bit different in the Magento 2.2.7 version.

Step - 1

First of all, you need to add $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path)); before if (!is_array($directories)) {.

Step - 2

After that, you need to change if (0 === strpos($this->fileDriver->getRealPath($path), $directory)) { to if (0 === strpos($realPath, $directory)) {.

After making the above changes, the code should look like below:

Fix Blank Admin Page Issue Magento 2

Step - 3

Lastly, save the changes and refresh the Magento 2 admin page to check if the blank admin page issue is resolved or not.

Fix Blank page Admin Issue Magento 2

Also read: How to Create New Admin User in Magento 2?

Conclusion

Magento 2 is the most powerful and a highly-preferred eCommerce platform in the market. But, many store owners have faced this error.

Hopefully, you’ve learned how to resolve the Magento 2 blank admin page error from this tutorial.

However, if you still need our professional assistance with your Magento 2 Development, reach out to us at any time for help.