Error: "Server under pressure"
After setting up Directus, I've attempted to run 'npx directus-template-cli@latest apply' in order to apply the AgencyOS template. However after selecting the template, entering my URL and access token I get the following output:
=== Applying template - AgencyOS to [url]
Loading 76 collections and 700 fields... done Loading 176 relations... done Loading 4 roles... done Loading 5 policies... done Loading 415 permissions... done Loading 5 users... done Loading 5 accesses... done Loading 17 folders... done -- Server under pressure. Retrying after 5000ms -- Retrying job (attempt 1) -- Server under pressure. Retrying after 5000ms -- Retrying job (attempt 1) -- Server under pressure. Retrying after 5000ms -- Retrying job (attempt 1) -- Server under pressure. Retrying after 5000ms -- Retrying job (attempt 1)
Even after waiting a long time it just keeps on retrying without any success.
The error logs in "/.directus/.directus-template-cli/logs" unfortunately don't contain any information except "Log started at 2025-03-10T03-28-01-306Z".
I've checked my server utilization and everything looks fine (meaning neither my CPU nore memory usage are anywhere near full capacity). I'm using Ubuntu 22.04.5 LTS in case this might be relevant.
Content of my docker-compose.yaml file:
version: '3'
services:
database:
image: mysql:8.0
# Required when running on platform other than amd64, like Apple M1/M2:
# platform: linux/amd64
ports:
- 3307:3306
volumes:
- ./data/database:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: '[password]'
MYSQL_USER: '[user]'
MYSQL_PASSWORD: '[password]'
MYSQL_DATABASE: '[db]'
command: --default-authentication-plugin=mysql_native_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 5s
retries: 10
cache:
image: redis:6
directus:
image: directus/directus:11.5.1
ports:
- 8055:8055
volumes:
- ./uploads:/directus/uploads
- ./extensions:/directus/extensions
depends_on:
database:
condition: service_healthy
environment:
KEY: '[key]'
SECRET: '[secret]'
DB_CLIENT: 'mysql'
DB_HOST: 'database'
DB_PORT: '3306'
DB_DATABASE: '[db]'
DB_USER: '[user]'
DB_PASSWORD: '[password]'
CACHE_ENABLED: 'false'
CACHE_STORE: 'redis'
REDIS: 'redis://cache:6379'
ADMIN_EMAIL: '[email]'
ADMIN_PASSWORD: '[password]'
# These is helpful for local developement but should probably be removed in production
# CORS_ENABLED: 'true'
# REFRESH_TOKEN_COOKIE_DOMAIN: 'localhost'
# EXTENSIONS_AUTO_RELOAD: 'true'
WEBSOCKETS_ENABLED: 'true'
# The default config prevents importing files from 0.0.0.0. See https://docs.directus.io/self-hosted/config-options.html#security . This can be removed in production but in local development it is recommended to keep it so you can import logos from Organization > website.
IMPORT_IP_DENY_LIST: ''
# Make sure to set this in production
# (see https://docs.directus.io/self-hosted/config-options#general)
PUBLIC_URL: '[url]'
Are there any methods to get more detailed error logs or common troubleshooting steps I should try? Any help would be greatly appreciated.
You're hitting the pressure limiter on your instance. Usually not an issue on development workloads, but that depends on your hardware obviously.
Here's the docs that cover the config settings for it. https://directus.io/docs/configuration/security-limits#pressure-based-rate-limiter
You can choose to turn it off if you want or dial back the settings a bit.
You're hitting the pressure limiter on your instance. Usually not an issue on development workloads, but that depends on your hardware obviously.
Here's the docs that cover the config settings for it. https://directus.io/docs/configuration/security-limits#pressure-based-rate-limiter
You can choose to turn it off if you want or dial back the settings a bit.
Thanks for the help. I've now used the provided default docker-compose.yaml file and otherwise only added the following lines:
RATE_LIMITER_ENABLED: 'false'
RATE_LIMITER_GLOBAL_ENABLED: 'false'
RATE_LIMITER_REGISTRATION_ENABLED: 'false'
PRESSURE_LIMITER_ENABLED: 'false'
However it still doesn't work, even on a new Hetzner cloud server I set up to test this. Apologies if I'm missing something obvious, would I have to otherwise configure the Docker container to have sufficient ressources available?
What are the specs of the server you've provisioned?
If you've turned off the pressure limiter and the rate limiter and you are still receiving the same error that seems very weird indeed.
Thanks again, really appreciate the help. I've set up the Hetzner 'CCX13' cloud server plan:
- 2 dedicated vCPU
- 8 GB RAM
- 80 GB NVMe SSD
While just testing this again, applying the AgencyOS template actually did work at one point for some reason:
However afterwards I naively removed this instance again in order to make sure applying the AgencyOS template now works (also since there were still errors related to 'Request Entity Too Large' and 'Invalid foreign key for field "directus_files_id"' displayed as shown in the above screenshot) and got the previous 'Server under pressure' again:
Afterwards I retried the process multiple times to make sure there's no factor of randomness or such resulting in the same errors again without any luck. What stands out to me is that when applying the template generally worked, the output while 'Loading 49 files' shows that after the first 'Request failed' it immediately proceeded with 'attempt 2' while also increasing the timeout in milliseconds (as opposed to the behaviour I experience otherwise where 'Retrying job' is done multiple times for each 'attempt' with the same timeout values of 5000ms). Seemingly indicating that the issue might be related to the pressure limiter actually not being disabled if I'd have to guess.
Here's also the entire docker-compose.yaml file I've used (both when it worked and most recently didn't work):
version: '3'
services:
database:
image: postgis/postgis:13-master
ports:
- 5432:5432
volumes:
- ./data/database:/var/lib/postgresql/data
environment:
POSTGRES_USER: '[user]'
POSTGRES_PASSWORD: '[password]'
POSTGRES_DB: '[db]'
cache:
image: redis:6
directus:
image: directus/directus:11.5.1
ports:
- 8055:8055
volumes:
- ./uploads:/directus/uploads
- ./extensions:/directus/extensions
depends_on:
- cache
- database
environment:
KEY: '[key]'
SECRET: '[secret]'
DB_CLIENT: 'pg'
DB_HOST: 'database'
DB_PORT: '5432'
DB_DATABASE: '[db]'
DB_USER: '[user]'
DB_PASSWORD: '[password]'
CACHE_ENABLED: 'false'
CACHE_STORE: 'redis'
REDIS: 'redis://cache:6379'
ADMIN_EMAIL: '[email]'
ADMIN_PASSWORD: '[password]'
CORS_ENABLED: 'true'
REFRESH_TOKEN_COOKIE_DOMAIN: 'localhost'
EXTENSIONS_AUTO_RELOAD: 'true'
WEBSOCKETS_ENABLED: 'true'
IMPORT_IP_DENY_LIST: ''
# Rate limiter adjustments
RATE_LIMITER_ENABLED: 'false'
RATE_LIMITER_GLOBAL_ENABLED: 'false'
RATE_LIMITER_REGISTRATION_ENABLED: 'false'
PRESSURE_LIMITER_ENABLED: 'false'
PUBLIC_URL: '[url]'
In case this issue hasn't been brought up by others I assume it might be related to my specific setup and I don't expect you to assist with further troubleshooting given this is a open source application. If you think it's worth inspecting further I'm happy to provide any relevant logs or try other steps though of course. Either way thanks a lot for your work.
I ran into the same issue after creating a project using npx directus-template-cli@latest init and discovered that it was a permission issue, as some of the directories were owned by root.
Running the following command inside the directus directory solved the issue for me:
sudo chown -R $USER data extensions uploads
After restarting the container, I could successfully apply the template with npx directus-template-cli@latest apply.
Disabling the rate/pressure limiters was not necessary, everything worked fine with the default docker-compose.yaml after fixing the permissions.
@jgierer12 how exactly you did it? In order to run the command for the directories permissions I need to stop the CLI and start it over again. Then the CLI ask to overwrite the directory, which restarts the issue.
Am I missing something? Feeling dumb for not being able to figure out such a silly thing haha. Thanks in advance!
can recreate this as well. can you add bug label on to it as this is a bug.
cmd: npx directus-template-cli@latest init --frontend=nextjs --template=cms
\\_//
( Õ Õ) "Let's create a new Directus project!"
C(")(")
┌ Directus Template CLI - Create Project
│
◇ Would you like to install project dependencies automatically?
│ Yes
│
◇ Initialize a new Git repository?
│ Yes
│
◇ Docker containers running!
│
◇ Directus is ready!
Applying template from: /home/redacted/directus/template
-- Logged in as Admin User
Loading 24 collections and 276 fields... done
Loading 66 relations... done
Loading 4 roles... done
Loading 7 policies... done
Loading 149 permissions... done
Loading 3 users... done
Loading 12 accesses... done
Loading 4 folders... done
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Request failed. Retrying after 1000ms
-- Retrying job (attempt 1)
-- Request failed. Retrying after 1000ms
-- Retrying job (attempt 1)
-- Request failed. Retrying after 1000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Request failed. Retrying after 2000ms
-- Retrying job (attempt 2)
-- Request failed. Retrying after 2000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 3)
-- Request failed. Retrying after 4000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Request failed. Retrying after 4000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Request failed. Retrying after 4000ms
-- Retrying job (attempt 3)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 5)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 5)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 4)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 5)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Request failed. Retrying after 1000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 6)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Max retries reached, not retrying further
No chunk id map found
No chunk id map found
› Warning: Error: fetch failed
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 1)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 7)
-- Request failed. Retrying after 2000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Server under pressure. Retrying after 5000ms
-- Retrying job (attempt 2)
-- Request failed. Retrying after 4000ms
-- Retrying job (attempt 3)
Loading 32 files... ⣷
^C
After disabling all limiters and looking at the Directus logs docker compose logs -f Directus I noticed I was actually running into write permissions issues like:
directus-1 | [09:57:08] PATCH /folders/ed033970-538d-4034-9a70-332e90104178 200 20ms
directus-1 | [09:57:08] PATCH /folders/f123c546-cde3-41f8-9375-1321a65d6564 200 18ms
directus-1 | [09:57:08] GET /files?fields=id%2Cfilename_disk&limit=-1 200 14ms
directus-1 | [09:57:08.504] WARN: Couldn't save file 08177527-b867-47e9-b5d5-eab146b3cdba.jpg
directus-1 | [09:57:08.505] WARN: EACCES: permission denied, open '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'
directus-1 | err: {
directus-1 | "type": "Error",
directus-1 | "message": "EACCES: permission denied, open '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'",
directus-1 | "stack":
directus-1 | Error: EACCES: permission denied, open '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'
directus-1 | "errno": -13,
directus-1 | "code": "EACCES",
directus-1 | "syscall": "open",
directus-1 | "path": "/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg"
directus-1 | }
directus-1 | [09:57:08.514] WARN: Couldn't delete file 08177527-b867-47e9-b5d5-eab146b3cdba.jpg
directus-1 | [09:57:08.515] WARN: ENOENT: no such file or directory, unlink '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'
directus-1 | err: {
directus-1 | "type": "Error",
directus-1 | "message": "ENOENT: no such file or directory, unlink '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'",
directus-1 | "stack":
directus-1 | Error: ENOENT: no such file or directory, unlink '/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg'
directus-1 | at async unlink (node:internal/fs/promises:1067:10)
directus-1 | at async DriverLocal.delete (file:///directus/node_modules/.pnpm/@directus+storage-driver-local@file+packages+storage-driver-local/node_modules/@directus/storage-driver-local/dist/index.js:59:3)
directus-1 | at async cleanUp (file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected][email protected][email protected]/node_modules/@directus/api/dist/services/files.js:83:21)
directus-1 | at async FilesService.uploadOne (file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected][email protected][email protected]/node_modules/@directus/api/dist/services/files.js:113:13)
directus-1 | at async Multipart.<anonymous> (file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected][email protected][email protected]/node_modules/@directus/api/dist/controllers/files.js:89:32)
directus-1 | "errno": -2,
directus-1 | "code": "ENOENT",
directus-1 | "syscall": "unlink",
directus-1 | "path": "/directus/uploads/08177527-b867-47e9-b5d5-eab146b3cdba.jpg"
directus-1 | }
directus-1 | [09:57:08] POST /files 503 52ms
This matches with the fact that I was getting the Server under pressure errors in the files step, where it is trying to create files in the uploads folder. This step happens after Loading 17 folders... done. The other people in this issue also to experience this at the same moment.
So I think the biggest issue that directus-template-cli is showing a file write permissions issue as a " Server under pressure" error.
The response error code 503 is actually commonly used for "Come back later." kind of issues, and a write permission error isn't that. Directus should probably report this error with a 500?
This happens because, at least for me, Docker creates the uploads as root user, while Directus is a regular user (1000). If this folder was pre-created as regular user there would be no issue. I think this is the second issue.
(People also recommend specifying the user field in the Directus service, but as long as the user in the Directus container (1000) by default) matches the user who created the folders I think it should be fine without this.)
So maybe these folders can simply be included in the template with .gitkeep files I think this would prevent the permission issue.
For me the workaround was:
- Running once:
npx directus-template-cli@latest init - Then resetting almost everything
cd directusdocker compose down -vsudo rm -rf data extensions uploadsmkdir data extensions uploadsdocker compose up -dcd ../
- Apply template to existing folder:
npx directus-template-cli@latest apply
In my case, I was getting this error because my STORAGE_GCS configuration was incorrect and failing to add the files to the bucket.
I've also opened an issue to discuss whether 503 is even appropriate for these types of errors. https://github.com/directus/directus/issues/26501
I'm hoping this was resolved with 88 -- over in the starters repo. Still an issue?
Closing this out. The fix that worked here (thanks @jgierer12) was folder permissions, not the limiters. If data, extensions, or uploads are owned by root, Directus can't write files and requests back up. From the directus folder:
sudo chown -R $USER data extensions uploads
Then restart the container and apply again. Reopen if you still see it after that.