You picked Medusa v2 for control over the checkout, the data and the payment flow. The next question is where to run it without a large monthly bill before the first sale. A Hetzner cloud server with Coolify gives you Git-push deploys, SSL and a dashboard on a machine you rent. This guide covers the production setup: the build, the Redis modules, the admin-login cookie failure (GitHub #11769), migrations that hang on deploy, SSL, backups, and what you take on by hosting it yourself.
Most Medusa deployment guides stop at "it works on localhost". Production breaks in other places: the admin login loops because the session cookie is not saved, the migration hangs because Medusa forces SSL on a database it thinks is remote, and the workflow engine loses in-flight runs on restart if it is still in memory. I lead commerce and infrastructure work at MithTech, a team of Frappe specialists in Bengaluru that also builds on Medusa, and we run open-source stacks with Coolify on Hetzner.
What does it cost against Shopify?
Self-hosting swaps a platform bill for a server bill plus your time. On Hetzner you pay for the server, any extra volumes, backups and object storage; Medusa and Coolify have no licence fee. On Shopify you pay a monthly plan fee, app fees, and an extra transaction fee when you don't use Shopify Payments. Check both vendors' price pages on the day you decide: Hetzner's prices change from time to time, and Shopify's fees vary by plan and country.
The line most comparisons leave out is people. Someone has to run upgrades, backups, monitoring and security patches. If you have a developer who can run Docker, self-hosting is usually cheaper. If you would hire one just for this, put that cost in before you compare.
Which server to start on
Hetzner's CAX servers use Ampere ARM processors and its CX and CPX servers use x86. ARM is cheaper per core, but every image you run must have an ARM64 build. Node, PostgreSQL and Redis publish ARM64 images; you build the Medusa image yourself, so it follows the server. Some community plugins ship native code that may not; check before you commit.
Hetzner lists cloud locations in Germany, Finland, Singapore and the USA, and not every server type is offered everywhere. Pick the location closest to your customers that has the type you want, and keep the database in the same location as the app.
The production issues that break deployments
Admin login loops back to the login page (GitHub #11769)
The admin loads, you sign in, and you land back on the login screen. The login worked; the session cookie was not saved, so the next request is not authorised. In #11769, opened on v2.6.0, the causes reported were:
- CORS origins that don't match.
ADMIN_CORSmust be the exact origin the admin is served from (with the admin at/appon the server, that is the server's URL), andAUTH_CORSmust include it too. A maintainer noted a CORS bug in v2.6.0 fixed in v2.6.1. - A proxy that hides HTTPS. Medusa sets a secure cookie only when it knows the request came over HTTPS. Coolify's Traefik passes
X-Forwarded-Proto; if you add Cloudflare or another proxy in front, each layer must forward it and trust the one before it.
Turning off secure cookies makes login work, which proves the diagnosis, but don't leave it that way in production.
Migrations hang with no error
medusa db:migrate prints that the migrations table was created, then sits there. The confirmed cause: Medusa treats any database host that is not localhost or 127.0.0.1 as remote and forces SSL, and a stock Postgres container does not speak TLS. A Docker service name such as db triggers it. Set databaseDriverOptions: { connection: { ssl: false } } in medusa-config.ts for a database on the same private network.
A separate report of a hang only on ARM64 Linux (#16011) was closed by the stale bot on 12 August 2026 without a fix. If you hit it, run migrations from an x86 machine. The full diagnosis is in why medusa db:migrate hangs.
Builds that break on an upgrade
Medusa's dependency tree is large. In July 2025 a transitive zod change broke fresh installs with Package subpath './v3' is not defined by 'exports' (#12933), fixed in Medusa by PR #12938. In January 2026, v2.12.4 added a step to the build command and broke some custom Dockerfiles (#14474).
Commit your lockfile, install with npm ci so the build uses it, read the release notes, and try each upgrade on staging first.
The in-memory modules lose state
Out of the box, Medusa's event bus, workflow engine and locking run in memory. When the container restarts (a deploy, a crash, a health-check restart), in-flight workflow runs such as cart completion are lost. Medusa's deployment guide lists the Redis-backed modules for production: @medusajs/medusa/event-bus-redis, @medusajs/medusa/workflow-engine-redis, @medusajs/medusa/locking with locking-redis, and @medusajs/medusa/caching with @medusajs/caching-redis.
The deployment, step by step
0 of 6 steps done
Tick a step’s number when it is done; the ticks stay on this device.
Provision the Hetzner server
In the Hetzner Cloud Console, create a server with at least 2 GB of RAM in the location closest to your customers. Add your SSH public key. Attach a Cloud Firewall that allows TCP 22, 80 and 443 and nothing else.
Install Coolify
SSH into the server and run Coolify's install script from the Coolify docs. It installs Docker, sets up its own database for its settings and starts the dashboard on port 8000. Create your admin account on first visit, then put the dashboard behind your domain.
Add PostgreSQL, Redis and the app
Create PostgreSQL and Redis as Coolify resources, or deploy one docker-compose with all three. Connect your Git repository so Coolify deploys on push. Set DATABASE_URL, REDIS_URL, JWT_SECRET, COOKIE_SECRET, STORE_CORS, ADMIN_CORS and AUTH_CORS in Coolify's environment panel, never in the repository.
Build, migrate and start
Follow Medusa's deployment guide: run medusa build, which writes the server to .medusa/server; in that folder run npm install, then npm run predeploy (migrations), then npm run start. The build needs your dev dependencies, so install them in the build stage. For more traffic, run a second instance as the worker with MEDUSA_WORKER_MODE=worker and DISABLE_MEDUSA_ADMIN=true. Create the first admin with npx medusa user -e <email> -p <password>.
Add domain and SSL
Create a DNS A record pointing api.your-store.com at the server. In Coolify, add the domain to the service; Coolify issues a Let's Encrypt certificate and routes traffic through its proxy.
Verify
Check that https://api.your-store.com/health returns OK, sign into the admin at /app, and work through the checklist below.
What is on the production checklist?
- Firewall allows only 22, 80 and 443; SSH by key only.
JWT_SECRETandCOOKIE_SECRETare long random values, set in Coolify, not in Git.STORE_CORS,ADMIN_CORSandAUTH_CORShold the exact HTTPS origins.- Admin login survives a page reload (the session cookie is saved).
- Event bus, workflow engine, locking and caching use the Redis modules.
databaseDriverOptionsmatches how your Postgres handles SSL.- Migrations run in
predeploy, before the new version starts. /healthis wired to Coolify's health check and to an outside uptime monitor.- Postgres has automated backups to storage off the server, and you have tested a restore.
- Uploaded product images are in object storage, or backed up with the database.
- OS security updates are on, and images are rebuilt on a schedule.
What to know before you commit
You own the uptime. Hetzner's cloud page states a 99.9% uptime SLA (checked 12 October 2026); that covers their infrastructure, not your application. If Medusa crashes at 2 a.m., you are on call. Coolify's health checks and restarts help; they don't replace monitoring on /health.
Backups are yours too. With Postgres in a container, schedule pg_dump to S3-compatible storage such as Hetzner Object Storage, and test a restore. Hetzner's server backups and snapshots are a paid add-on and copy the whole disk; they are not a substitute for database dumps.
Security patching. Hetzner doesn't patch your server. Turn on unattended security upgrades and rebuild images on a schedule. Read npm audit output with care: in #14993 (v2.13.1), Medusa's team found that several flagged packages were used only by the CLI and didn't affect running servers.
| Shopify | ||
|---|---|---|
| Monthly cost | Server, storage and backups at Hetzner's rates | Plan fee plus paid apps |
| Transaction fees | Only your payment gateway's | Shopify Payments, or an extra fee when you use another gateway |
| Customisation | Full source code | Liquid themes, apps and APIs |
| Uptime responsibility | You | Shopify |
| Scaling | Resize the server or add instances yourself | Handled by the platform |
| Data | Your server, your database | On Shopify's platform; exported through its tools and APIs |
| Payment gateways | Any, through a payment provider module | Shopify Payments or supported third-party gateways |
Medusa self-hosted on Hetzner and Shopify: trade-offs beyond price
Should you run Medusa on Hetzner yourself, or have it run for you?
Run it yourself if a developer on your team can own the Coolify host, the Postgres dumps, the patching and the 2 a.m. restart; the steps above are then the whole job. Have it run for you if the store is how you earn and nobody on the team should be its on-call engineer.
Do it yourself if
You have a developer who runs Docker and Postgres with confidence, you will test a restore before launch, and an hour of checkout downtime would hurt but not sink the month.
Have it run for you if
Orders come in around the clock, a failed upgrade during a sale is a real loss, or you moved off Shopify for control, not for server work.
Under managed hosting we run Medusa on one named server in your cloud account or ours: nightly backups copied off it, one restored on a schedule, every upgrade tried on a copy first, and the keys stay yours. It is a monthly fee for running it plus the server, quoted in writing after a call.
Common questions about Medusa on Coolify
How much does it cost to self-host Medusa v2 on Hetzner?
Medusa and Coolify have no licence fee, so you pay Hetzner for the server, storage, backups and object storage, plus a domain. One server can run Medusa, PostgreSQL and Redis for a small store. Check Hetzner's current price page for the server type and location you choose, and count the time someone spends running it.
Can I run Medusa v2 on an ARM64 server?
Yes. Node, PostgreSQL and Redis publish ARM64 images, and you build your Medusa image on the same architecture. Check that any plugin with native code supports ARM64. If medusa db:migrate hangs, first rule out forced SSL (the common cause); an ARM64-only hang was reported in #16011 and closed without a fix, and running migrations from an x86 machine avoids it.
Why does the Medusa admin keep sending me back to the login page in production?
The session cookie isn't being saved. Set ADMIN_CORS and AUTH_CORS to the exact HTTPS origin of the admin, and make sure every proxy in front of Medusa forwards X-Forwarded-Proto: https, so Medusa knows to set a secure cookie. These were the fixes reported in #11769.
Should I use Coolify or deploy Medusa manually with Docker?
Coolify gives you Git-push deployments, automatic SSL, health-check restarts and a dashboard on your own server. A manual Docker setup with nginx gives you more control, but you write the deploy scripts, certificate renewal and restarts yourself. For most teams Coolify is less to maintain.
How do I fix the zod subpath error when building Medusa?
The error Package subpath './v3' is not defined by 'exports' (#12933) came from a transitive dependency in July 2025. Medusa fixed it in PR #12938, so upgrade Medusa. On an older version, the maintainer's stopgap was pinning zod-validation-error to 3.4.1. Delete node_modules and reinstall afterwards.
What version of Medusa does this deployment guide cover?
Medusa v2. It was written on v2.18.0; the latest release when we checked on 12 October 2026 was v2.21.2. The build steps and Redis modules follow Medusa's general deployment guide. Pin your versions and test each upgrade on staging.
Is Hetzner reliable enough for production e-commerce?
Hetzner's cloud page states a 99.9% uptime SLA with service credits. That covers their hardware and network; your application's uptime is yours. Put a CDN in front of the storefront, monitor /health, and keep tested database backups off the server.
What happens if my Hetzner server goes down?
Coolify restarts the Medusa container if it crashes. For a server failure you restore from a snapshot or backup to a new server and restore the database from your latest dump, so test that path before you need it. Two servers behind a load balancer remove the single point of failure, at the cost of a shared database and Redis.
Medusa on Hetzner with Coolify gives you every line of your commerce stack on a server you rent. In exchange you own the uptime, the backups and the patches. With a developer who can run Docker, that trade is worth it early; without one, count the cost of that person before you compare bills.
Comments & ratings
No comments yet. Start a new discussion.
Manoj · Published on 4 August 2026
Worked with us? Leave a Google review