I created an AWS ECS Service on Fargate using n8n docker hub image ‘n8nio/n8n:latest’. The service uses EFS with access point that mounts to ‘/home/node/.n8n’. The EFS access point’s uid and gid is set to 1000:1000 and permission 0755. The VPC security groups allow the EFS traffic. The EFS system policy is set to allow “elasticfilesystem:ClientRootAccess”, “elasticfilesystem:ClientWrite”, “elasticfilesystem:ClientMount”. But I couldn’t start up the service successfully on ECS Fargate due to some directory access issue. Any help is appreciated.
What is the error message (if any)?
…
root: /usr/local/lib/node_modules/n8n
code: EACCES
message: EACCES: permission denied, open ‘/home/node/.n8n/config’
See more details with DEBUG=*
(Use node --trace-warnings ... to show where the warning was created)
…
Please share your workflow
n/a
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
I can’t access the container as the ECS service cannot start up properly. The task was deprovisioned before it reached the running state. Here’s the volume details of the task definition and EFS access point config. Do you see any problems?
Before I tried 0777, I noticed a config file was created under ‘/home/node/.n8n’. And the config file has ‘-rw-r–r–. 1 1000 1000 56 Apr 4 05:55 config’. Then I created a new access point with 1000:1000 and 0777 and tried to redeploy and launch the service on Fargate, the container exit with code 1. And there’s no CloudWatch log any more. What else can I try?
Dont know ECS service, i try to brainstorm with you.
n8n image run under a non-root user called node
If you have the UID and GID of the ‘node’ user from the n8n container, (maybe) you could update values on your EFS access point
Hi, seems it’s not the EFS problem. I removed EFS from Task Definition and redeployed the service, it still crashed with container exit code: 1. No log items in the CloudWatch log file. What else shall I try?
Hi, did you try with the template?
Even a simple test actually using the exact template should give you a definite answer on what is going on. You could use terraform and API keys and it can be tested in 30min.
Hi, we use CloudFormation and AWS CDK instead of terraform. Since this is not really urgent for us, will look into the template later. Thanks for the response.
you’re running into a permissions error (EACCES) because the n8n Docker container running in AWS Fargate cannot write to the mounted EFS directory /home/node/.n8n — even though you’ve seemingly set UID/GID and permissions correctly.
Your service name will be used in naming your resources like log groups, ECS services, etc.
name: n8n
type: Load Balanced Web Service
Distribute traffic to your service.
http:
Requests to this path will be forwarded to your service.
To match all requests you can use the “/” path.
path: ‘/’
You can specify a custom health check path. The default is “/”.
healthcheck:
path: ‘/healthz’
healthy_threshold: 2 # number of consecutive health check successes required before considering an unhealthy target healthy
unhealthy_threshold: 4 # number of consecutive health check failures required before considering a target unhealthy
interval: 30s # amount of time, in seconds, between health checks
timeout: 10s # amount of time, in seconds, during which no response from a target means a failed health check
grace_period: 360s # grace period within which to provide containers time to bootstrap before failed health checks count towards the maximum number of retries
deregistration_delay: 30s # amount of time to wait for targets to drain connections during deregistration. align with n8n graceful shutdown timeout
Configuration for your containers and service.
image:
location: n8nio/n8n:latest # The location of n8n image in the Docker Hub.
location: n8nio/n8n:stable
Port exposed through your container to route traffic to it.
port: 5678
cpu: 1024 # Number of CPU units for the task.
memory: 2048 # Amount of memory in MiB used by the task.
count: 1 # Number of tasks that should be running in your service.
platform: linux/x86_64
platform: linux/arm64
exec: true # Enable running commands in your container.
Storage configuration for n8n
storage:
volumes:
n8n-data:
path: ‘/home/node/.n8n’ # Mount path inside the container where n8n stores data.
read_only: false
efs:
id:
auth:
iam: true
access_point_id:
mount_points:
source_volume: n8n-data # Must match the name under storage.volumes
container_path: /home/node/.n8n # The required path inside the n8n container
read_only: false