Showing results for 
Search instead for 
Did you mean: 

Magento 2.0 seems working only on localhost


Magento 2.0 seems working only on localhost


I just installed Magento 2.0 on a VirtualBox VM with Ubuntu 15.10, compiling apache .htaccess as adviced and giving directory permissions as described in the installation guide.

It works fine if I access Magento from the VM browser (using http://localhost/magento2, or a 2nd level domain), but it seems not working if I try to access from the host machine. If I try to write:

it turns into:


and then I get a 404 error and it can't load the page.


The Vm is connected in bridged mode (IP address is and from the host machine I can easily access the phpmyadmin and phpinfo of the guest machine (i.e.: works well!).


I tried to install Magento2 several times, first using localhost as "host name", then with and then with a 2nd level domain but the results connecting from the host machine were that the address turned, respectively:


https://<2nd level domain>/magento2/?SID=pm5sih457aov00ojaa6tldqbs1

always getting the same error.


Some help would be really appreciate.


Thanks in advance.


Re: Magento 2.0 seems working only on localhost

This is most likely due to the Base URL being set as localhost.

Try changing the Base URL in Magento Admin --> Store --> Configuration --> Web, clear all caches and see if it works.
James Lee | Moderator • Magento Master
See My Recommended Magento Hosting & Security Tips

Re: Magento 2.0 seems working only on localhost

Thanks for your help.

Trying only to change the base URL replacing it with a domain name, I still got the problem.

So I solved it adding an entry on my host's "hosts" file relating the guest VM IP and the domain name.

Re: Magento 2.0 seems working only on localhost

Go to Document Root/pub

Find .htaccess and add

RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*)$1 [L,R=301]



This should solve the issue. For me this work in M2.1


All the best.