Symptom
A new instance, or one that just rebooted, can't mount EFS. The error tells you which part of this checklist to start with:
| Error | Usually means | Start at |
|---|---|---|
mount.nfs4: Connection timed out or the mount hangs | No network path to a mount target on TCP 2049 | Checks 1 and 2 |
Failed to resolve "fs-...efs....amazonaws.com" | No mount target in this AZ, or VPC DNS settings off | Checks 1 and 3 |
mount: unknown filesystem type 'efs' | amazon-efs-utils not installed | Check 4 |
access denied by server while mounting | File system policy or IAM denies the client | Check 5 |
mounting access_point failed, reason given by server: No such file or directory | Access point root directory doesn't exist and can't be created | Check 6 |
| Instance hangs at boot or drops to emergency mode | Bad /etc/fstab entry without _netdev or nofail | Check 7 |
This checklist covers mounts that fail. If the mount works but I/O is slow or hangs later, that's a throughput or burst credit problem, not a mount problem.
Set these once for the commands below:
FS=fs-0123456789abcdef0
INSTANCE=i-0123456789abcdef0
Check 1: a mount target exists in the instance's AZ
aws ec2 describe-instances --instance-ids $INSTANCE \
--query 'Reservations[].Instances[].{AZ:Placement.AvailabilityZone,Subnet:SubnetId,Vpc:VpcId,SGs:SecurityGroups[].GroupId}'
aws efs describe-mount-targets --file-system-id $FS \
--query 'MountTargets[].{Id:MountTargetId,AZ:AvailabilityZoneName,Subnet:SubnetId,Ip:IpAddress,State:LifeCycleState,Vpc:VpcId}' \
--output table
- There's a mount target in the same VPC as the instance, with
LifeCycleState=available. - There's a mount target in the instance's AZ. The file system DNS name only resolves to a mount target in the caller's own AZ.
- For a One Zone file system, the instance is in that zone, or you mount with the mount target IP and accept cross-AZ traffic.
If an AZ has no mount target, create one:
aws efs create-mount-target --file-system-id $FS \
--subnet-id subnet-0abc --security-groups sg-0efs
A file system can have mount targets in only one VPC at a time. To mount from a peered VPC or from on premises, use the mount target IP (see Check 3).
Check 2: security groups allow NFS on TCP 2049
MT=$(aws efs describe-mount-targets --file-system-id $FS \
--query 'MountTargets[?AvailabilityZoneName==`us-east-1a`].MountTargetId' --output text)
aws efs describe-mount-target-security-groups --mount-target-id $MT
aws ec2 describe-security-groups --group-ids sg-0efs \
--query 'SecurityGroups[].IpPermissions[?ToPort==`2049`]'
- The mount target's security group allows inbound TCP 2049 from the instance's security group or subnet CIDR.
- The instance's security group allows outbound TCP 2049. The default all-traffic outbound rule covers this.
- Network ACLs on both subnets allow TCP 2049 inbound to the mount target, and the return ephemeral ports back to the instance.
Test the port from the instance:
timeout 5 bash -c "</dev/tcp/10.0.1.25/2049" && echo open || echo blocked
Replace 10.0.1.25 with the mount target IP for the instance's AZ. If this says blocked, the mount will time out. Fix the network before you look at anything else.
Tip
Rather than listing CIDRs, give the mount target security group one inbound rule: TCP 2049 from the client security group. New instances in that group can mount without a rule change.
Check 3: DNS resolves the file system name
dig +short $FS.efs.us-east-1.amazonaws.com
aws ec2 describe-vpc-attribute --vpc-id vpc-0123 --attribute enableDnsSupport
aws ec2 describe-vpc-attribute --vpc-id vpc-0123 --attribute enableDnsHostnames
- Both VPC attributes are
true. - The instance uses the Amazon-provided resolver (the VPC +2 address, or
169.254.169.253). Custom DNS servers in/etc/resolv.confmust forwardamazonaws.comqueries to it.
If DNS can't work from where the client sits, as with a peered VPC, on premises or another account, mount by IP. With efs-utils:
sudo mount -t efs -o tls,mounttargetip=10.0.1.25 $FS:/ /mnt/efs
Or with the plain NFS client:
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport \
10.0.1.25:/ /mnt/efs
Check 4: amazon-efs-utils is installed and working
# Amazon Linux 2023
sudo dnf install -y amazon-efs-utils
# Ubuntu, RHEL and others: build or install the package as described in the efs-utils README
rpm -q amazon-efs-utils 2>/dev/null || dpkg -l amazon-efs-utils
which stunnel stunnel5 2>/dev/null
sudo tail -n 50 /var/log/amazon/efs/mount.log
-
mount -t efsis recognised. If it isn't, the package is missing. - With the
tlsoption, stunnel is installed. efs-utils uses it to wrap NFS in TLS. -
mount.logshows no certificate, stunnel orbotocoreerrors. efs-utils settings live in/etc/amazon/efs/efs-utils.conf. Log paths and options can vary by efs-utils version, so check your version's README.
Run the mount by hand to see the full error before you touch fstab:
sudo mkdir -p /mnt/efs
sudo mount -t efs -o tls $FS:/ /mnt/efs
df -hT /mnt/efs
Check 5: IAM and the file system policy allow the client
If you mount with the iam option, or the file system policy requires it, the instance role must have the right elasticfilesystem client actions.
aws efs describe-file-system-policy --file-system-id $FS --query Policy --output text
aws sts get-caller-identity # run on the instance; confirms which role it uses
| Action | Needed for |
|---|---|
elasticfilesystem:ClientMount | Read-only mount |
elasticfilesystem:ClientWrite | Writes |
elasticfilesystem:ClientRootAccess | Acting as root (UID 0) without root squashing |
- The instance profile role allows the actions you need, on the file system ARN.
- The file system policy doesn't deny the role. Look for
Denystatements onaws:SecureTransport=false(this needs thetlsoption) or on specific access points. - If the policy requires IAM, the mount command includes
iam(which also needstls):
sudo mount -t efs -o tls,iam $FS:/ /mnt/efs
Warning
Changing the file system policy affects every client at once. Before tightening it, for example by requiring TLS or IAM, check that all current clients already mount with
tlsandiam. If they don't, they'll getaccess deniedon their next mount or reboot.
Check 6: the access point is valid
aws efs describe-access-points --file-system-id $FS \
--query 'AccessPoints[].{Id:AccessPointId,Path:RootDirectory.Path,Creation:RootDirectory.CreationInfo,Posix:PosixUser,State:LifeCycleState}'
- The access point
LifeCycleStateisavailable. - Either the root directory path already exists, or
CreationInfo(owner UID, GID and permissions) is set so EFS can create it on first mount. A missing path with noCreationInfoproducesNo such file or directory. - The
PosixUserUID/GID has permission on that directory.
sudo mount -t efs -o tls,iam,accesspoint=fsap-0123456789abcdef0 $FS:/ /mnt/app
You can't change an access point's root path or POSIX user after you create it. To change either, create a new access point and switch clients over to it.
Check 7: fstab won't hang the boot
A working entry for efs-utils:
fs-0123456789abcdef0:/ /mnt/efs efs _netdev,nofail,tls,iam 0 0
-
_netdevis set, so the mount waits for the network. -
nofailis set, so an unreachable EFS doesn't drop the instance into emergency mode. -
sudo mount -asucceeds before you reboot.
If an instance is already stuck at boot because of fstab, use the EC2 serial console, or detach the root volume and fix /etc/fstab from a rescue instance.
Prevent it next time
- Create a mount target in every AZ your workloads use, in the same template as the subnets.
- Use one client security group referenced by the mount target security group on TCP 2049.
- Bake amazon-efs-utils into the AMI and always mount with
tls(andiamif the policy requires it). - Always put
_netdev,nofailin fstab, and test withmount -ain your build pipeline. - Test file system policy changes on one client before applying them to the whole fleet.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get