Closed princessfrombabylon99 closed 1 day ago
@shahednasser Kindly help
Console Log
Thanks for opening the issue! Looking at your instructions, doesn't seem like you created a user.
Can you try running the following command in your deployed Medusa application's directory:
npx medusa user -e admin@medusajs.com -p supersecret
You can replace admin@medusajs.com
and supersecret
with the email and password you want.
Then, try to login again.
Thanks for opening the issue! Looking at your instructions, doesn't seem like you created a user.
Can you try running the following command in your deployed Medusa application's directory:
npx medusa user -e admin@medusajs.com -p supersecret
You can replace
admin@medusajs.com
andsupersecret
with the email and password you want.Then, try to login again.
Still get this
Do I need to make any changes to .env? FYI Apart from this the installation wizard did show 'Creating user' message
I can't see in the first screenshot, did it say the user was created successfully? And did you make sure to use the same credentials as in the command when logging in?
Below are my .env and env.local
.env
MEDUSA_ADMIN_ONBOARDING_TYPE=nextjs
STORE_CORS=http://localhost:8000,https://docs.medusajs.com,
ADMIN_CORS=http://localhost:5173,http://localhost:9000,https://docs.medusajs.com,
AUTH_CORS=http://localhost:5173,http://localhost:9000,https://docs.medusajs.com,
REDIS_URL=redis://localhost:6379
JWT_SECRET=supersecret
COOKIE_SECRET=supersecret
DB_NAME=medusa-my-store
DATABASE_URL=postgres://tropicana:*******@localhost/$DB_NAME
MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY=my-store-storefront
env.local
# Your Medusa backend, should be updated to where you are hosting your server. Remember to update CORS settings for you>
NEXT_PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000
# Your publishable key that can be attached to sales channels. See - https://docs.medusajs.com/development/publishable->
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_7ea867cb63dedKEY-GOES-HERE364ed801ff912255a2b9b641daeda0c7
# Your store URL, should be updated to where you are hosting your storefront.
NEXT_PUBLIC_BASE_URL=http://localhost:8000
# Your preferred default region. When middleware cannot determine the user region from the "x-vercel-country" header, t>
NEXT_PUBLIC_DEFAULT_REGION=us
# Your Stripe public key. See – https://docs.medusajs.com/add-plugins/stripe
NEXT_PUBLIC_STRIPE_KEY=
# Your PayPal Client ID. See – https://docs.medusajs.com/add-plugins/paypal
NEXT_PUBLIC_PAYPAL_CLIENT_ID=
# Your MeiliSearch / Algolia keys. See – https://docs.medusajs.com/add-plugins/meilisearch or https://docs.medusajs.com>
NEXT_PUBLIC_FEATURE_SEARCH_ENABLED=false
NEXT_PUBLIC_SEARCH_APP_ID=
NEXT_PUBLIC_SEARCH_ENDPOINT=http://127.0.0.1:7700
NEXT_PUBLIC_SEARCH_API_KEY=
NEXT_PUBLIC_INDEX_NAME=products
# Your Next.js revalidation secret. See – https://nextjs.org/docs/app/building-your-application/data-fetching/fetching->
REVALIDATE_SECRET=supersecret
I can't see in the first screenshot, did it say the user was created successfully? And did you make sure to use the same credentials as in the command when logging in?
First screenshot shows the following information
ubuntu@ip-my-ip:~/my-store$ npx medusa user -e admin@medusajs.com -p supersecret
redisUrl not found. A fake redis instance will be used.
warn: Local Event Bus installed. This is not recommended for production.
info: Locking module: Using "in-memory" as default.
info: No job to load from /home/ubuntu/my-store/node_modules/@medusajs/medusa/dist/jobs. skipped.
Why are you using .env
files in production? You should use system environment variables instead. Also, it seems like you don't have NODE_ENV=production
.
I actually have a PR for a general deployment guide here that should be available in the docs soon. Might be useful to follow for your deployment.
But I don't believe that's the issue. If you created a user with email admin@medusajs.com
and password supersecret
, you should be able to login with it. Make sure you're using the correct credentials or maybe try creating a different user with a different email and password, then try logging in with that user.
Why are you using
.env
files in production? You should use system environment variables instead. Also, it seems like you don't haveNODE_ENV=production
.I actually have a PR for a general deployment guide here that should be available in the docs soon. Might be useful to follow for your deployment.
But I don't believe that's the issue. If you created a user with email
admin@medusajs.com
and passwordsupersecret
, you should be able to login with it. Make sure you're using the correct credentials or maybe try creating a different user with a different email and password, then try logging in with that user.
Yes, tried creating different users also couple of times. Well this is the issue . I am not using any external DB or Redis , Installed it as we install on a local ubuntu machine.
system environment variables
I understand what you mentioned about system environment variables. Do you have any documentation for AWS? But , I am still thinking, even if I don't use system environment variables and keep the variables with source code, I should be able to at-least login and explore, if it is working localhost , why not on live server?
@shahednasser I am going to install Coolify on my AWS instance and see how things go; ideally, it should work, as Coolify is an alternative to Vercel.
Meanwhile, I'm still wondering why the Medusa installation wizard asked me for a database name but didn’t use the database I created. Instead, it created another one on its own. This question is still lingering in my mind.
An EC2 instance is essentially the same as an Ubuntu machine, so I should have been able to log in to the admin panel. Changing the CORS settings to allow access from a specific IP might have fixed the issue, but I’m giving up on that for now. Let’s move on to Coolify!
Meanwhile, I'm still wondering why the Medusa installation wizard asked me for a database name but didn’t use the database I created. Instead, it created another one on its own. This question is still lingering in my mind.
create-medusa-app
creates a new database every time you run it. You can change .env
to point to the database you created and run npx medusa db:setup
. You can also pass to create-medusa-app
a --db-url
option with its value the connection URL to your database.
I am going to install Coolify on my AWS instance and see how things go; ideally, it should work, as Coolify is an alternative to Vercel.
That's unrelated really. The Medusa server can't be deployed to vercel anyway.
Your application seems to be connecting fine to the database, and has the correct configuration. The only possible issue I can think of is that you're creating the user in a different application that's connected to a different database or something similar.
Meanwhile, I'm still wondering why the Medusa installation wizard asked me for a database name but didn’t use the database I created. Instead, it created another one on its own. This question is still lingering in my mind.
create-medusa-app
creates a new database every time you run it. You can change.env
to point to the database you created and runnpx medusa db:setup
. You can also pass tocreate-medusa-app
a--db-url
option with its value the connection URL to your database.I am going to install Coolify on my AWS instance and see how things go; ideally, it should work, as Coolify is an alternative to Vercel.
That's unrelated really. The Medusa server can't be deployed to vercel anyway.
Could I install Medusa server using Coolify? I understand vercel is used to install front-end or back-end. I am again little confused now🥺. I want to use Medusa within AWS. If I use coolify, could you please tell me how can I go about installing medusa server? *I am going through learning , please don't mind if I ask such basic questions. I so want to use Medusa in production for my start-up.
Your application seems to be connecting fine to the database, and has the correct configuration. The only possible issue I can think of is that you're creating the user in a different application that's connected to a different database or something similar. Maybe you're right.
If you need step-by-step help, then i recommend Railway as we already have a guide for it:
https://docs.medusajs.com/resources/deployment/medusa-application/railway
Or you can use the railway guide as a blue print for your deployment.
@shahednasser If I break it in a laymans language. Medusa - is a server, that can be installed on Ubuntu server. admin - can be installed using vercel, coolify etc. front-end - can be installed using vercel , coolify etc.
Then I need to configure these 3 things to talk to each other by configuring , system variables , db urls, CORS etc.
That's true. Although you can deploy the admin with the backend. The storefront needs to always be deployed separately.
That's true. Although you can deploy the admin with the backend. The storefront needs to always be deployed separately.
When you say backend , you mean medusa server+admin panel? Since front-end is in NextJs , it needs a platform to deploy.
Okay , I think , I got it now!
@shahednasser One of my colleague tried it on a local Ubuntu machine, he was able to login. However, when we checked db, it shows that Medusa created another db and did not use the one that we provided during installation wizard . Medusa basically used Posgres user with 'CREATE' privileges and created a fresh db and overlooked the one that was given to it. Please check the screenshots below.
it shows that Medusa created another db and did not use the one that we provided during installation wizard
Can you share how you provided the database? Can you share the command you used?
@shahednasser During the Installation , on below screen.
What's the name of your project? my-store ? Would you like to create the Next.js storefront? You can also create it later Yes ? Enter your Postgres username tropicana ? Enter your Postgres password [hidden] ? Enter your Postgres user's database name jungle 🚀 Starting project setup, this may take a few minutes. ✔ Created project directory ✔ Installed Next.js Starter successfully in the my-store-storefront directory.
So I think there's a misunderstanding here. The "Enter your Postgres user's database name" is not the database name that Medusa uses, it's the name of the PostgreSQL user's database (learn more here).
If you want to specify a database to use, provide a database connection URL with --db-url
like this:
npx create-medusa-app@latest --db-url "postgres://user:password@localhost:5432/my-database"
Of course change the URL based on your database. Then, if the command can connect to the database, it will use it instead of creating another one. otherwise the installation will fail
@shahednasser Thank you.
Let me know if it works!
@shahednasser I’ll keep you posted. I’m reading more about Medusa now, as it sounds more interesting. Without your help, I wouldn’t have been able to figure out where I was going wrong. As entrepreneurs, we’re used to opens-source monolithic apps, where we run a few CLI commands and get things working, as the frontend and backend remain tightly integrated. This is the first time we’re using headless ecommerce, and it looks more modern, SEO-friendly, and promising. I’m reading your docs now to understand most of it.
That's great to hear! Then as the original issue is resolved, I'll close this issue. Feel free to open another if you face other problems!
Package.json file
Node.js version
20.18.0
Database and its version
psql (PostgreSQL) 16.4 (Ubuntu 16.4-0ubuntu0.24.04.2)
Operating system name and version
Ubuntu 24.04
Browser name
Chrome and Safari
What happended?
Below are the commands Created a new ec2 instance Updated the repo
sudo apt update && sudo apt upgrade -y
Corrected the time.zone
sudo timedatectl set-timezone "Asia/Kolkata"
Reboot
sudo reboot
Installed Nginx
sudo apt install nginx
Installed Node 20
NPM
sudo apt install npm
Installed YarnConfigured Yarn (Not sure , if I did this correct, I just found this on internet)
Added the following line:
export PATH="$PATH:
yarn global bin"`source ~/.bashrc
Installed Postgres 16
Created user, db named 'jungle' and granted the user all PRIVILEGES on db jungle
Install Redis
ubuntu@my-ip $ npx create-medusa-app@latest
Today , I was logged in as ubuntu user not root, I used ChatGPT and it gave the following solution
So , I changed it to md5 and ran one more command
ALTER USER tropicana WITH CREATEDB;
This time the Medusa got installed. I had previously tried it install it as root user , however, it never threw such errors.
I got a message my server is running at localhost:9000
I used Letsencrypt and also NGINX configuration is below ( modified the server-names)
Below is the nginx.conf
I went on my URL For front-end , I got
GET / Which is okay, because it is giving me a hint that something needs to be configured.
I went on to log in my admin panel
URL/app/
I tried creating another user , but no luck.
My one more question is , If I created a database named 'jungle' , why did Medusa create another datebase during installation and Medusa named that database as medusa-my-store , Shouldn't it use the database that I created and assigned to it?
Now , I am stuck at point. I have no idea , no clue what to do next. I checked YouTube, reddit, GitHub, Stockoverflow and all forums, however, as you know , very limited documentation is available about Medusa.
Expected behavior
Admin Panel with no console errors
Actual behavior
Console Errors , unable to connect.
Link to reproduction repo
https://github.com/medusajs/medusa