#MedusaJS Deployment Issue: Admin URL Stuck on Localhost
31 messages · Page 1 of 1 (latest)
In your medusa config, set
admin: {
backendUrl: <yourURL>,
},
I have set admin backendUrl as a process.env at the bottom of my config but it still like to localhost:9000 even though in my env it’s https://frontline.netgurusolutions.co.uk
try hard-coding it and see if it works. This envvar is used at build-time, so if it is not set at build time you'll get this issue
when i do this i get errors on yarn start
PS E:\frontline-military\frontline-military> yarn build
yarn run v1.22.22
$ medusa build
{"level":"info","message":"Starting build...","timestamp":"2024-10-25 11:06:43"}
{"level":"info","message":"Compiling backend source...","timestamp":"2024-10-25 11:06:43"}
{"level":"info","message":"Removing existing \".medusa\\server\" folder","timestamp":"2024-10-25 11:06:43"}
{"level":"info","message":"Compiling frontend source...","timestamp":"2024-10-25 11:06:43"}
{"level":"info","message":"Backend build completed successfully (2.52s)","timestamp":"2024-10-25 11:06:45"}
{"level":"info","message":"Frontend build completed successfully (13.95s)","timestamp":"2024-10-25 11:06:57"}
Done in 15.80s.
PS E:\frontline-military\frontline-military> yarn start
yarn run v1.22.22
$ medusa start
{"level":"info","message":"Skipping instrumentation registration. No register function found.","timestamp":"2024-10-25 11:07:00"}
redisUrl not found. A fake redis instance will be used.
{"level":"warn","message":"Local Event Bus installed. This is not recommended for production.","timestamp":"2024-10-25 11:07:00"}
{"level":"warn","message":"No default locking provider explicit defined. Using \"in-memory\" as default.","timestamp":"2024-10-25 11:07:01"}
{"level":"info","message":"No job to load from E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\dist\\jobs. skipped.","timestamp":"2024-10-25 11:07:05"}
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
{"level":"error","message":"Error starting server","stack":[{"columnNumber":11,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\admin-bundler\\dist\\index.js","functionName":"serve","lineNumber":1344,"methodName":null,"native":false,"typeName":null},{"columnNumber":28,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\admin.ts","functionName":"serveProductionBuild","lineNumber":75,"methodName":null,"native":false,"typeName":null},{"columnNumber":3,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async loadEntrypoints","lineNumber":108,"methodName":null,"native":false,"typeName":null},{"columnNumber":31,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async exports.default","lineNumber":164,"methodName":"default","native":false,"typeName":"async exports"},{"columnNumber":50,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async internalStart","lineNumber":120,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async start","lineNumber":221,"methodName":null,"native":false,"typeName":null}],"timestamp":"2024-10-25 11:07:05"}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS E:\frontline-military\frontline-military>
I am assuming that the NODE_ENV === "production", so in that case make sure that you have a .env.production file, as that is the only env file that will be loaded in production
i have done that but still getting localhost:9000
PS E:\frontline-military\frontline-military> yarn start
yarn run v1.22.22
$ medusa start
{"level":"info","message":"Skipping instrumentation registration. No register function found.","timestamp":"2024-10-25 17:46:22"}
{"level":"warn","message":"Local Event Bus installed. This is not recommended for production.","timestamp":"2024-10-25 17:46:22"}
{"level":"warn","message":"No default locking provider explicit defined. Using \"in-memory\" as default.","timestamp":"2024-10-25 17:46:23"}
{"level":"info","message":"No job to load from E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\dist\\jobs. skipped.","timestamp":"2024-10-25 17:46:27"}
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1610:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)
{"level":"error","message":"Error starting server","stack":[{"columnNumber":11,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\admin-bundler\\dist\\index.js","functionName":"serve","lineNumber":1344,"methodName":null,"native":false,"typeName":null},{"columnNumber":28,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\admin.ts","functionName":"serveProductionBuild","lineNumber":75,"methodName":null,"native":false,"typeName":null},{"columnNumber":3,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async loadEntrypoints","lineNumber":108,"methodName":null,"native":false,"typeName":null},{"columnNumber":31,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async exports.default","lineNumber":164,"methodName":"default","native":false,"typeName":"async exports"},{"columnNumber":50,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async internalStart","lineNumber":120,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"E:\\frontline-military\\frontline-military\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async start","lineNumber":221,"methodName":null,"native":false,"typeName":null}],"timestamp":"2024-10-25 17:46:27"}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS E:\frontline-military\frontline-military>
this is with production env and also wont even start now hahah
PS E:\frontline-military\frontline-military> yarn start
yarn run v1.22.22
$ medusa start
info: Skipping instrumentation registration. No register function found.
redisUrl not found. A fake redis instance will be used.
warn: Local Event Bus installed. This is not recommended for production.
error: Could not resolve module: Workflows. Error: Loaders for module Workflows failed: No database specified, please fill in dbName or clientUrl option
error: Error starting server
Error: Loaders for module Workflows failed: No database specified, please fill in dbName or clientUrl option
at runLoaders (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\loaders\utils\load-internal.ts:667:14)
at async loadInternalModule (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\loaders\utils\load-internal.ts:286:17)
at async loadModule (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\loaders\module-loader.ts:82:10)
at async moduleLoader (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\loaders\module-loader.ts:21:32)
at async Function.bootstrap_ (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\medusa-module.ts:476:9)
at async Function.bootstrapAll (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\medusa-module.ts:302:12)
at async loadModules (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\medusa-app.ts:152:19)
at async MedusaApp_ (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\medusa-app.ts:384:22)
at async MedusaApp (E:\frontline-military\frontline-military\node_modules@medusajs\modules-sdk\src\medusa-app.ts:585:10)
at async MedusaAppLoader.load (E:\frontline-military\frontline-military\node_modules@medusajs\framework\src\medusa-app-loader.ts:246:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS E:\frontline-military\frontline-military>
new error i have my db set and all auth and admin and store set
sooo after changing back to .env instead of .env.production it loads up but now it wont login
can we update node_modules@medusajs\types\dist\common\config-module.d.ts
/**
* Configure the application's worker mode.
*
* Workers are processes running separately from the main application. They're useful for executing long-running or resource-heavy tasks in the background, such as importing products.
*
* With a worker, these tasks are offloaded to a separate process. So, they won't affect the performance of the main application.
*
* 
*
* Medusa has three runtime modes:
*
* - Use `shared` to run the application in a single process.
* - Use `worker` to run the a worker process only.
* - Use `server` to run the application server only.
*
* In production, it's recommended to deploy two instances:
*
* 1. One having the `workerMode` configuration set to `server`.
* 2. Another having the `workerMode` configuration set to `worker`.
*
* @example
* ```js title="medusa-config.js"
* module.exports = defineConfig({
* projectConfig: {
* workerMode: process.env.WORKER_MODE || "shared"
* // ...
* },
* // ...
* })
* ```
*/
workerMode?: "shared" | "worker" | "server" | process.env.WORKER_MODE;
i keep getting ts error when building with workerMode: process.env.WORKER_MODE, and also workerMode: process.env.WORKER_MODE || "shared",
anyone able to help with this as im smashing my head off the wall
anyone ??
Hi @winged bramble, did you follow the guide on using standalone builds? You can find it here: https://docs.medusajs.com/resources/medusa-cli/commands/build#run-built-medusa-application
Setting the worker mode to shared, should not disable the admin, just tested it and admin is spun up in that mode. The only one that disables it is "worker".
For your env variables, the loadEnv util that is called in medusa-config.ts, will load the .env file that corresponds to your NODE_ENV, so if NODE_ENV is production (NODE_ENV=production medusa start) it will load .env.production, if NODE_ENV=staging it will load .env.staging, and in all other cases it will load .env. For a production deployment you would want to make sure that NODE_ENV is actually set to production, and in that case it will look for .env.production.
If you can't login once the server is up and running try sharing which error you are getting, particularly in your server logs.
@cerulean oak thank you for your reply i have got it working as a server thought railway
import { loadEnv, defineConfig } from '@medusajs/framework/utils';
// Load environment variables
loadEnv(process.env.NODE_ENV || 'development', process.cwd());
module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
redisUrl: process.env.REDIS_URL,
workerMode: "shared",
http: {
storeCors: process.env.STORE_CORS!,
adminCors: process.env.ADMIN_CORS!,
authCors: process.env.AUTH_CORS!,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
},
},
admin: {
disable: process.env.DISABLE_MEDUSA_ADMIN === "true",
backendUrl: process.env.MEDUSA_BACKEND_URL,
path: '/app'
},
modules: [
{
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
{
resolve: "@medusajs/medusa/event-bus-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
{
resolve: "@medusajs/medusa/workflow-engine-redis",
options: {
redis: {
url: process.env.REDIS_URL,
},
},
},
{
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/medusa/file-s3",
id: "s3",
options: {
file_url: process.env.S3_FILE_URL,
access_key_id: process.env.S3_ACCESS_KEY,
secret_access_key: process.env.S3_SECRET_KEY,
region: process.env.S3_REGION,
bucket: process.env.S3_BUCKET,
endpoint: process.env.S3_ENDPOINT,
additional_client_config: {
forcePathStyle: true,
},
},
},
],
},
},
],
});
now im just trying to get admin working i was now thinking of building my own in next js 15 ad a monorepo with store front but sturggling to get started as been fighting with the backend
You need to share some info for me to help you figure out why admin isn't working for you. What errors are you seeing?
yarn run v1.22.22
$ medusa start
{"level":"info","message":"Skipping instrumentation registration. No register function found.","timestamp":"2024-10-30 09:50:05"}
{"level":"info","message":"Connection to Redis in module 'cache-redis' established","timestamp":"2024-10-30 09:50:05"}
{"level":"info","message":"Connection to Redis in module 'event-bus-redis' established","timestamp":"2024-10-30 09:50:06"}
{"level":"info","message":"Connection to Redis in module 'workflow-engine-redis' established","timestamp":"2024-10-30 09:50:09"}
{"level":"info","message":"Connection to Redis PubSub in module 'workflow-engine-redis' established","timestamp":"2024-10-30 09:50:10"}
{"level":"warn","message":"No default locking provider explicit defined. Using \"in-memory\" as default.","timestamp":"2024-10-30 09:50:10"}
{"level":"info","message":"No job to load from E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\dist\\jobs. skipped.","timestamp":"2024-10-30 09:50:29"}
{"level":"error","message":"Error starting server","stack":[{"columnNumber":11,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\admin-bundler\\dist\\index.js","functionName":"serve","lineNumber":1344,"methodName":null,"native":false,"typeName":null},{"columnNumber":28,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\src\\loaders\\admin.ts","functionName":"serveProductionBuild","lineNumber":75,"methodName":null,"native":false,"typeName":null},{"columnNumber":3,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async loadEntrypoints","lineNumber":108,"methodName":null,"native":false,"typeName":null},{"columnNumber":31,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\src\\loaders\\index.ts","functionName":"async exports.default","lineNumber":164,"methodName":"default","native":false,"typeName":"async exports"},{"columnNumber":50,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async internalStart","lineNumber":120,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"E:\\frontline-military\\railwaybuild\\my-medusa-store\\node_modules\\@medusajs\\medusa\\src\\commands\\start.ts","functionName":"async start","lineNumber":221,"methodName":null,"native":false,"typeName":null}],"timestamp":"2024-10-30 09:50:29"}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS E:\frontline-military\railwaybuild\my-medusa-store>
this is what i get when i set
in my env and env.production
DISABLE_MEDUSA_ADMIN=false
MEDUSA_BACKEND_URL=http://192.168.68.129:9000
even when i deploy alli get is 'Error starting server' ive done the normal put in to chat, and all i get is that i should set
admin: {
disable: process.env.DISABLE_MEDUSA_ADMIN === "true",
backendUrl: process.env.MEDUSA_BACKEND_URL,
path: '/app'
},
path to '/admin' but that is used for api calls soo i cant that why its set to /app like docs tell me too
@cerulean oak
id i do yarn dev its works but yarn start doesnt
The error looks like aren't starting your server from the correct path, again this is how you start a production build of Medusa: https://docs.medusajs.com/resources/medusa-cli/commands/build#run-built-medusa-application
In short your pibeline should look like this:
- Run
medusa build - Copy
.env.productionto the./medusa/serverfolder - CD into
./medusa/serverfolder - Run
medusa start
If you run medusa start from the root path instead of the .medusa/server folder then it won't be able to resolve the admin path.
Also if you are using Docker, and your root path is /app then make sure to change the path in the admin options to something else, such as /dashboard as described here: https://docs.medusajs.com/resources/troubleshooting#errors-in-docker
im sorry i must sound stupid right now but on railways .app
https://docs.medusajs.com/resources/deployment/medusa-application/railway
i followed this to try and host both server and adminn on there but that is the error i am getting how do i change the deploy dirc on there ??
You could change the "start" command in your package.json to something like this: cd ./medusa/server && yarn install && medusa start
Medusa v2 has many bugs and limitations. Does anyone know which version of Medusa is stable?
What are the bugs and limitations you've faced @rotund quiver ? We are fixing every bug with the highest priority so it'd be good to create issues for them
I had same problem 2 days ago after following railway guide #1301927173573054484 message. I think build/start commands should be updated in that guide, based on https://docs.medusajs.com/resources/medusa-cli/commands/build#run-built-medusa-application. Unless I misunderstood something.
Currently my build command for workedMode: shared, which is deployed on railway is:
"build": "medusa build && (cd .medusa/server && yarn install)",
"start": "cd .medusa/server && medusa start",
It seems less hacky than copying public folder
hey, does this go in the packeage.json or as the custom sart
@winged bramble what Medusa version where you using when you resolved the create-fulfillment-workflow definition already existing? I am experiencing this in v 2.7.0 and i am, unable to deploy. How did you resolve it?
Hey sorry I don’t remember I got it all working recently with fulfillment and stripe and minio and resend every time I had an error it was me messing it up on the Medusa config