Skip to content
Blog

Strapi "Blocked request. This host is not allowed" fix

Strapi v5 /admin shows "Blocked request. This host is not allowed" on your domain? It comes from Vite, not config/server.ts. Here is what to change.

The Liite team6 min read

Short answer

This error comes from Vite's dev server, not from Strapi's own server, so allowedHosts in config/server.ts is never read. Run the production build (npm run build, then npm run start) so no Vite dev server is involved. If you must use strapi develop behind a hostname, add server.allowedHosts in src/admin/vite.config.ts.

You put Strapi v5 on a VPS, pointed a hostname at it, and /admin now shows a plain error page instead of the login screen:

Blocked request. This host ("strapi.example.com") is not allowed.

You added allowedHosts to config/server.ts and nothing changed. That is expected, and the sections below explain why and what to change instead.

Why it happens

Strapi v5 builds its admin panel with Vite. When you start the app with strapi develop, the admin is served by Vite's development server. Vite added a host check to that dev server in security releases in early 2025. It compares the Host header of each request with a list of allowed hosts and refuses anything else. The full message usually continues like this:

To allow this host, add "strapi.example.com" to server.allowedHosts in vite.config.js.

By default Vite allows localhost and IP addresses, but not an arbitrary domain name. That is why the panel works at http://localhost:1337/admin or at a raw IP and breaks as soon as a domain points at the server.

config/server.ts configures Strapi's own HTTP server: host, port, url, app keys and so on. Vite never reads that file, so a key added there has no effect.

People on Strapi's community forums report exactly this: the setting added, the error unchanged. In the thread we found, nobody had a confirmed fix, and one suggestion to change the public URL didn't help either. The steps below come from how Vite and Strapi are documented to work, not from a fix confirmed in that thread. If your versions differ, check Strapi's official documentation for your release.

Causes at a glance

CauseSymptomFix
Dev server running on a public hostError on your domain, fine on localhost or the IPUse the production build
Service still runs strapi developYou built for production but the error persistsFix the pm2 or systemd start command
Domain not in Vite's allow listError names your domainAdd it in src/admin/vite.config.ts
Setting placed in config/server.tsNo change after restartMove it to the Vite config

Step-by-step fixes

The first fix is the proper one for a server. The third is for when you really need the dev server reachable by hostname.

1. Run the production build instead of develop

Build the admin once, then start Strapi in production mode:

NODE_ENV=production npm run build
NODE_ENV=production npm run start

In production Strapi serves the prebuilt admin files itself. There is no Vite dev server, so there is no host check to trip. Use a process manager such as pm2 or systemd to keep it running.

2. Check what your service actually runs

If you already believe you run in production and still see the error, open your systemd unit or pm2 config and read the start command.

  1. Look for strapi develop or npm run develop in the command.
  2. Replace it with npm run start.
  3. Make sure NODE_ENV=production is set in the service environment.
  4. Restart the service and reload /admin.

A start command that still says develop is a common reason the dev server is running without you noticing.

3. If you must use strapi develop behind a hostname

Customize the admin's Vite config. Strapi v5 documents src/admin/vite.config.ts as the place to do this:

import { mergeConfig, type UserConfig } from 'vite';

export default (config: UserConfig) => {
  return mergeConfig(config, {
    server: {
      allowedHosts: ['strapi.example.com'],
    },
  });
};

Restart the dev server after saving. Vite also accepts allowedHosts: true, which turns the check off.

Don't disable the check on a public server

The check exists to block DNS rebinding attacks against dev servers. Use allowedHosts: true only on a machine that isn't reachable from the internet.

4. Set the public URL

In config/server.ts, set url to the address people actually use, for example https://strapi.example.com. This doesn't cure the Vite error by itself. It does prevent wrong links and login redirects once the admin loads.

What won't help

  • allowedHosts in config/server.ts. It is not a Strapi server option, so Vite never sees it.
  • Changing only url. Useful for other problems, but the block happens before the admin loads, so the error stays.
  • Rewriting the Host header in your reverse proxy. If Nginx passes an upstream address such as localhost:1337 as the Host, the dev server may stop complaining. That hides the check instead of configuring it, and it can break redirects and cookies. Forwarding the original host with proxy_set_header Host $host; is the normal setup, and with it the Vite check still applies in development.
  • Pasting configuration from an AI answer without checking it. In the thread, one such suggestion didn't work. Confirm any key against the Strapi docs for your version.

Confirm which mode is running

Check the startup log. If it mentions a development server or file watching, you are not in production mode, whatever your scripts say.

Checklist before you try again

  • The domain in the error message is exactly the one you put in allowedHosts, with no scheme and no port.
  • The config is in src/admin/vite.config.ts, not config/server.ts.
  • You restarted the process after saving.
  • Your service file does not run strapi develop if this is a public server.
  • Nginx or your proxy forwards the original host with proxy_set_header Host $host;.
  • url in config/server.ts matches the public address.

If nothing works

Ask in Strapi's official community channels or open an issue in the Strapi GitHub repository. Include the exact error text, your Strapi version (npm ls @strapi/strapi), your Node version, the command that starts the app, your src/admin/vite.config.ts, and your proxy config. Say which fixes you already tried.

Strapi v5.x on a VPS behind Nginx. /admin at https://strapi.example.com shows:
"Blocked request. This host ("strapi.example.com") is not allowed."
Works at http://localhost:1337/admin.
Start command: <your command>. NODE_ENV: <value>.
I added server.allowedHosts: ['strapi.example.com'] in src/admin/vite.config.ts and restarted.
Also tried allowedHosts in config/server.ts (no change).
Nginx forwards Host with proxy_set_header Host $host;
Node: <version>. Strapi: <version>. Config files attached.

Common questions

Does this affect Strapi v4?

Strapi v4 used webpack for the admin by default, so this Vite message points to v5 or a project that switched to Vite. Check your version with npm ls @strapi/strapi.

Why does it work on localhost but not on my domain?

The check looks at the Host header. localhost and IP addresses are on Vite's default allow list, and your domain isn't until you add it.

Is running strapi develop in production a problem for other reasons?

Yes. Development mode watches files, rebuilds the admin on change and doesn't use production settings. It is meant for your own machine, so the production build is the better answer even if the error goes away.

Can I list several domains?

Yes. allowedHosts takes an array, so add each hostname as its own string.