Skip to content
Medusa

How to install Medusa v2 step by step (Medusa.js tutorial)

Medusa is an open-source, headless commerce platform built with Node.js and TypeScript. Unlike WooCommerce or Shopify, you get a backend with commerce APIs and a modern admin dashboard, and you build (or plug in) your own storefront. In this tutorial, we will learn how to install Medusa v2 on your own machine or server, step by step: prerequisites, create-medusa-app, the admin user, and your first login to the Medusa Admin.

Everything below was done for real on a clean Ubuntu server with Medusa 2.23.2, the latest version at the time of writing. The terminal output in the screenshots is the actual output of each command (only long paths and the password are shortened).

Step 1: Install the prerequisites (Node.js and PostgreSQL)

Medusa v2 needs three things on your machine:

  • Node.js v22.22 or later (LTS). The generated project actually declares "node": ">=22.23.4" in its package.json, so install the newest Node 22 LTS.
  • PostgreSQL, installed and running. Any recent version works; I used PostgreSQL 16.
  • Git, because the installer clones the starter project.

Redis is optional for local development. Without it, Medusa falls back to in-memory modules and simply prints a warning. Check your versions before you start:

node -v
psql --version
pg_isready -h localhost -p 5432

medusa prerequisites node js and postgresql version check

If pg_isready answers no response, start PostgreSQL first (sudo systemctl start postgresql on Ubuntu, brew services start postgresql@16 on macOS). Then create a database user that is allowed to create databases. With the postgres superuser:

sudo -u postgres psql -c "CREATE ROLE medusa LOGIN CREATEDB PASSWORD 'choose-a-strong-password';"
sudo -u postgres createdb -O medusa medusa_demo

Step 2: Create the Medusa project with create-medusa-app

Medusa’s official installer is create-medusa-app. Run it with npx, give your project a name, and point it at your database with --db-url. The --seed flag adds demo data (a region, a sales channel and some sample products), which is very useful to explore the admin.

npx create-medusa-app@latest demo-store \
  --db-url "postgres://medusa:choose-a-strong-password@localhost:5432/medusa_demo" \
  --seed

The installer first asks “Would you like to install the storefront?”. Answer No if you only want the backend and admin for now (you can add the Next.js storefront later). It then creates the project directory, installs dependencies, runs the database migrations and finishes with Project Prepared. On my server the whole thing took about three minutes.

create-medusa-app install output project prepared

Useful flags: --no-browser stops the installer from opening the admin in a browser (handy on a server), --use-npm / --use-yarn / --use-pnpm force a package manager, and --with-nextjs-starter installs the storefront at the same time. Run npx create-medusa-app@latest --help to see them all.

What create-medusa-app created

Recent Medusa starters are monorepos. The Medusa application lives in apps/backend (and the storefront in apps/storefront if you installed it):

demo-store/
├── apps/
│   └── backend/
│       ├── medusa-config.ts   # main configuration
│       ├── .env               # DATABASE_URL, CORS, secrets
│       └── src/               # admin, api, jobs, links, modules, scripts, subscribers, workflows
├── package.json               # npm run dev / build / start (turbo)
└── turbo.json

Open apps/backend/.env and check DATABASE_URL. Before you go to production, replace the default JWT_SECRET and COOKIE_SECRET with long random strings.

Step 3: Create an admin user

You need an admin account to log in to the dashboard. Go to the backend folder and use the medusa user command:

cd demo-store/apps/backend
npx medusa user -e admin@example.com -p your-admin-password

medusa user command create admin user

The installer also prints an invite link (/app/invite?token=...) at the end, which lets you create the first admin user in the browser instead. Both methods work. The CLI is easier on a remote server.

Step 4: Start the Medusa server

From the project root, npm run dev starts everything through Turbo. To start only the backend, run npx medusa develop inside apps/backend. The development server watches your files and restarts automatically when you change code.

cd demo-store/apps/backend
npx medusa develop

Wait for Server is ready on port: 9000. The log also prints the admin URL.

medusa develop server ready on port 9000

The two warnings are normal in development: redisUrl not found means Medusa uses in-memory modules, and Local Event Bus installed means events are not sent through Redis. For production, add Redis and the Redis-based modules.

Step 5: Log in to the Medusa Admin

Open http://localhost:9000/app in your browser (replace localhost with your server IP or domain). Sign in with the email and password from Step 3 and click Continue with Email.

medusa admin login page

Step 6: Explore the demo store data

Because we used --seed, the admin already contains sample products (Medusa T-Shirt, Sweatshirt, Sweatpants and Shorts with their variants), a default sales channel and a region. Open Products to see them.

medusa admin products with seed sample data

Then go to Settings > Regions. A region in Medusa groups countries that share a currency, tax settings and payment providers. The seed created a “Europe” region, which you can edit or replace with your own markets.

medusa admin settings regions

Your next steps are usually: create your own region and currency under Settings, add a payment provider such as Stripe, create a publishable API key under Settings > Publishable API Keys for your storefront, and install the Next.js starter storefront.

Step 7 (optional): build and start Medusa for production

medusa develop is only for development. For a real server, the backend’s package.json already contains the production scripts: medusa build compiles the application and the admin dashboard, and medusa start runs the compiled build. From the project root, the equivalent commands are npm run build and npm run start. In production you should also set a real REDIS_URL, strong JWT_SECRET and COOKIE_SECRET values, and the correct domains in the CORS variables.

Common errors when installing Medusa

Couldn’t connect to PostgreSQL using the database URL

The installer checks the connection before doing anything. Make sure PostgreSQL is running, the user and password in --db-url are correct, and the database in the URL exists (create it with createdb first, as in Step 1).

The installer exits with “User force closed the prompt”

This happens when you run create-medusa-app in a non-interactive shell (CI, some SSH setups) and nobody answers the storefront question. Run it in a normal terminal, or pipe the answer in, for example printf 'n\n' | npx create-medusa-app@latest ....

Admin login shows an error or keeps loading

Check that the URL you use is listed in ADMIN_CORS and AUTH_CORS in apps/backend/.env. By default only localhost:9000, localhost:5173 and the Medusa docs site are allowed, so if you open the admin through a domain or IP, add it there and restart the server.

Engine “node” is incompatible

Your Node.js version is older than the one required by the project. Upgrade to the latest Node 22 LTS (with nvm install 22, for example).

If you come from the PHP world, the workflow will feel familiar: it is similar to creating an admin user in Magento 2 via the command line, just with npx medusa instead of bin/magento. And if you would rather stay on WordPress, see how to install WooCommerce on WordPress.

For all installer options, see the official create-medusa-app reference and the medusa user command documentation.

Related: [SOLVED] Medusa installation fails at "npx medusa db:migrate"

Related: Top best Medusa plugins for Medusa v2 (2026)

Wrapping up

That’s how to install Medusa v2: make sure Node.js 22 and PostgreSQL are ready, run create-medusa-app with your database URL, create an admin user with npx medusa user, start the server and log in at /app. From here you can add regions, payment providers and a storefront.

Did your installation stop at a step that is not covered here? Leave a comment below with the exact error message and I will help you sort it out.


Written by

Hung Tran

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2