Blocked Request Error in Medusa Admin

If you see the following error in the Medusa Admin's console:

Terminal
Blocked request. This host (X) is not allowed. To allow this host, add X to server.allowedHosts in vite.config.js.

Where X is the host that's being blocked. For example, example.com.

Why this Error Occurred#

This error occurs if you deploy Medusa but are using development mode (NODE_ENV=development). This can happen accidentally or unintentionally, but Medusa defaults NODE_ENV to production.

How to Fix it#

Option 1: Use Production Mode#

To resolve this error, ensure that you're running Medusa in production mode. You can set the NODE_ENV environment variable to production when starting Medusa:

Terminal
NODE_ENV=production

Option 2: Allow the Host#

If you intentionally want to use development mode in your deployed Medusa instance, you can allow the host that's being blocked using the admin.vite configuration in medusa-config.ts.

For example:

medusa-config.ts
1module.exports = defineConfig({2  // ...3  admin: {4    vite: () => {5      return {6        server: {7          allowedHosts: [".example.com"],8        },9      }10    },11  },12})

In the above example, you allow the host example.com to access the Medusa Admin. Make sure that when you replace example.com with your actual host, you include the leading . before the domain name.


Additional Resources#

Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break