#Admin panel: Server error - Try again later / ERR_CONNECTION_REFUSED

1 messages · Page 1 of 1 (latest)

woven cloud
#

I've deployed the Medusa 2.0 app (server, worker, and admin) to Railway and added an admin user via the Railway CLI. However, when I try to access the admin panel, I'm getting a "Server error - Try again later" message.

I'm not quite sure how to debug this. Any guidance would be really appreciated!

woven cloud
#

Looks odd that at the time of login, a request is sent to localhost.

Request URL: http://localhost:9000/auth/user/emailpass

variables on railway, server mode medusa:
COOKIE_SECRET="supersecret"
JWT_SECRET="supersecret"
STORE_CORS=""
ADMIN_CORS="https://xxx-server-dev.up.railway.app"
AUTH_CORS="https://xxx-server-dev.up.railway.app"
MEDUSA_BACKEND_URL="https://xxx-server-dev.up.railway.app"
DISABLE_MEDUSA_ADMIN="false"
MEDUSA_WORKER_MODE="server"
PORT="9000"
DATABASE_URL="${{Postgres.DATABASE_PUBLIC_URL}}"
REDIS_URL="${{Redis.REDIS_PUBLIC_URL}}"

Where Medusa is getting localhost:9000?

#

variables on railway, worker mode medusa:
COOKIE_SECRET="supersecret"
JWT_SECRET="supersecret"
DISABLE_MEDUSA_ADMIN="true"
MEDUSA_WORKER_MODE="worker"
PORT="9000"
DATABASE_URL="${{Postgres.DATABASE_PUBLIC_URL}}"
REDIS_URL="${{Redis.REDIS_PUBLIC_URL}}"

Admin is deployed with server mode - not separately.

silk drum
#

You need to set backendUrl in the admin options in medusa-config.js. The backendUrl should be the base URL of your deployed server, e.g. "https://www.myserver.com"

woven cloud
# silk drum You need to set `backendUrl` in the `admin` options in `medusa-config.js`. The `...

Thanks for the replay. We do have backendUrl in options.

Content of medusa-config.js:
const { loadEnv, defineConfig } = require("@medusajs/utils");
const { Modules } = require("@medusajs/utils");

loadEnv(process.env.NODE_ENV, process.cwd());

module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
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",
},
workerMode: process.env.MEDUSA_WORKER_MODE,
admin: {
disable: process.env.DISABLE_MEDUSA_ADMIN === "true",
backendUrl: process.env.MEDUSA_BACKEND_URL,
},
redisUrl: process.env.REDIS_URL,
},
modules: {
entryService: {
resolve: "./modules/entry",
},
[Modules.CACHE]: {
resolve: "@medusajs/cache-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
[Modules.EVENT_BUS]: {
resolve: "@medusajs/event-bus-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
[Modules.WORKFLOW_ENGINE]: {
resolve: "@medusajs/workflow-engine-redis",
options: {
redis: {
url: process.env.REDIS_URL,
},
},
},
},
services: {
entryService: {
resolve: "./modules/entry/service",
},
},
});

silk drum
#

Looks like you have the admin options inside of your projectConfig. The admin options go outside:

export default defineConfig({
  admin: { ... },
  projectConfig: { ... }
})