How to open your store when Magento 2 is not accessible in a browser

- E-Commerce, Fire development, Magento 2

Magento 2 export CLI

In the following article, we describe a situation when you are unable to access your Magento 2 storefront in a browser. Although the issue may seem terrifying is you face it for the first time, the resolution is quite fast and straightforward. Let’s take a look at a more detailed issue exploration and then describe how to open your Magento 2 website if it is not accessible in a browser. For further tips, follow this link: Magento 2 Cookbook.

PHP-related issues

Both your admin interface and frontend may not be accessible in a browser due to PHP-related issues. Upgrading it may solve the problem. Alternatively, you may also try to restart Apache.

The most common problem is accompanied by the following message:

It means that your PHP version may be outdated. Besides, Apache and the file system may use different PHP versions. That’s why upgrading php or simply restarting Apache may restore your access to Magento 2 in a browser.

Use the following command to restart Apache on Ubuntu:

For CentOS, you can restart Apache with the help of this command:

404 error

What if a 404 (Not Found) error displays? Two common issues cause error.

Apache server rewrites

You should check whether Apache server rewrites are enabled and correctly set. If they are misconfigured, the system cannot serve static files from the correct location.

By applying the correct configuration, you regain access to Magento 2 in a browser.

Base URL

You may also enter an incorrect base URL during the installation. Usually, users do one of the following:

  • Specify a wrong value of –base-url= in the command line;
  • Set an inappropriate value in the Your Store Address field on the Web Configuration page.

Remember that you should start the base URL with “http://” only. And it is possible to end it with nothing else but a trailing slash (/).

The only recommended resolution in this situation is to rerun the installer. Keep the rules mentioned above in mind when specifying a valid base URL value. When finished, access Magento 2 in a browser.

For further information, check the official troubleshooting guide.

503 error

You may also experience a 503 (Service Unavailable) error trying to access your Magento 2 website in a browser. It happens for both Magento Admin and storefront.

Firstly, you should find out whether the issue is related to maintenance mode or not. To do that, open your Apache error.log and find messages containing the following text:

The current problem is also based on Apache. Its version 2.4 changes the way specific directives work, especially the ones related to .htaccess. And since the Magento 2 software uses the latter to rewrite URLs, this may cause the problem. If .htaccess doesn’t work correctly, you can access neither the Magento 2 frontend not backed in a browser.

However, the issue is not typical for all Apache 2.4 distributions. Sometimes, a compatibility module is enabled by default. If the mod_access_compat module in your Apache 2.4 distribution is disabled, continue reading this section: we share the solution below.

Firstly, you have to login as a user with ‘root’ privileges.

Secondly, enter these commands:

For further information follow this link: 503 (Service Unavailable) Error. Don’t forget to replace <name> with httpd on CentOS. As for Ubuntu, use apache2 instead.

Images do not load

We would also like to draw your attention to a problem when images and stylesheets do not load. After installing Magento 2, you can see only texts. This problem is usually caused by the same factors we’ve mentioned above. Either an incorrect base URL or unproperly configures server rewrites make the path to images and stylesheets inaccurate.

First of all, you have to confirm this is the case. Check the paths to static assets using a web browser inspector. Those assets should be located on the Magento file system within the frontend and adminhtml directories under <magento_root>/pub/static/.

Everything is quite simple for the Apache webserver. You have to verify your server rewrites setting and your Magento server’s base URL as we’ve just mentioned above. Pay attention to the Apache AllowOverride directive since its incorrect configuration leads to the inability to serve the static files from the correct location.

As for the Nginx web server, you have to solve the issue differently. Configure a virtual host file properly, following the criteria below:

Firstly, the include directive must point to a sample Nginx configuration file. In its turn, the file should be stored in your Magento installation directory. The following example shows a possible solution:

Secondly, you have to configure the server_name directive. Note that it must match the base URL specified during the Magento 2 installation. For instance:

If your Magento 2 application is in production mode, you may also try another solution. Simply deploy static view files with the help of the following command:

magento setup:static-content:deploy

For further information, read this article: Images and stylesheets do not load in Magento 2.