Trying to follow this https://www.mageplaza.com/magento-2-module-development/ to create a module, but nothing is working for me. I am using Magento with xampp.

My root folder name is Magento2

path: C:\xampp\htdocs\Magento2\app\code\Mageplaza

created: HelloWorld folder


  • Controller folder
  • etc folder
  • registration.php



Inside etc folder:

  • frontend folder


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Mageplaza_HelloWorld" setup_version="2.0.0" />

Inside frontend folder


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="mageplaza" frontName="helloworld">
            <module name="Mageplaza_HelloWorld" />

Inside Controller folder:

  • Index folder

Inside Index folder:


namespace Mageplaza\HelloWorld\Controller\Index;

class Display extends \Magento\Framework\App\Action\Action
  public function __construct(\Magento\Framework\App\Action\Context $context)
    return parent::__construct($context);

  public function execute()
    echo 'Hello World';

url: http://localhost/Magento2/helloworld/index/display result: 404

Any idea where I am going wrong, just started learning magneto2.

  • 1
    Did you run php bin/magento setup:upgrade check you module in the list as well as cache:clean. Commented Oct 26, 2016 at 4:24
  • 2
    i check this code there is not problem in that i think you missed the php bin/magento setup:upgrade of install the module Commented Oct 26, 2016 at 5:15

9 Answers 9


Sometimes it fixes the issue after running the following command.

php bin/magento setup:di:compile

One other thing, make sure you've enabled your module.

bin/magento module:enable MyModule_Module bin/magenot setup:upgrade


Please Check with your Vendorname and the Modulename whether it is mentioned properly.Because I had the same issue due to misspelled modulename. But there is no issue on your coding.


When Create custom module than first u run command Below step by step

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy -f

php bin/magento cache:flush

Than run in url baseurl/helloworld/index/display

  • You don't need to call php bin/magento setup:static-content:deploy -f in developer mode.
    – Black
    Commented Sep 29, 2020 at 10:07

You must run the reindex command.

follow these steps

  1. php bin/magento setup:upgrade --keep-generated
  2. php bin/magento indexer:reindex

Note: --keep-generated argument is passed to keep generated static data. Otherwise you have to run setup:static-content:deploy command to regenerate all the static data.

Hope this will help.

  • Does not work either.
    – Black
    Commented Sep 29, 2020 at 10:06

This may be quite late response. Anyway hope this helps someone else to solve the issue.

In your routes.xml change the below line to have the same value as id and frontname

Before :

<route id="mageplaza" frontName="helloworld">

After :

<route id="helloworld" frontName="helloworld">

Clear cache and try again loading the page

NOTE : If you have different values for route id and frontname the routing will not work properly. Of course it would redirect you up to the controller function (if you echo something and exit from the controller the page would show the echoed wordings), but it would not load the relevant Block there. Obviously, the phtml file will not load.


Check \Magento\Framework\App\Router\ActionList::get (by setting a breakpoint) whether your controller class is actually instance of \Magento\Framework\App\ActionInterface - typos in namespace and use statements can prevent that - and it silently falls back to 404


Your problem is that you created the files in wrong directories.

You module.xml is in frontend folder but it should be in etc folder.


Also, please ensure that your controller is inside Controller/<action>/ directory, not inside Controller folder alone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.