Mounting Amazon EFS on EC2 hangs for minutes, then times out
Fix it fast
Most common cause, 1 of 4The mount target's security group has no inbound NFS rule from the instance
Add the inbound rule to the mount target's security group, naming the instance's security group as the source rather than a wide CIDR.
aws ec2 authorize-security-group-ingress --group-id sg-0aaaaaaaaaaaaaaaa \
--protocol tcp --port 2049 --source-group sg-0bbbbbbbbbbbbbbbbShort answer
mount.nfs: Connection timed out after a one- or two-minute hang means the instance never reached the EFS mount target on NFS port 2049. Usually the mount target's security group lacks inbound TCP 2049 from the instance; a narrowed outbound rule, a network ACL or a wrong mount target IP does the same. Allow 2049 between both groups and mount again.
Which cause do you have?
List the mount targets, then test the NFS port from the instance itself. Bash opens a plain TCP socket for /dev/tcp paths, so a five-second test separates a blocked port from a slow mount.
aws efs describe-mount-targets --file-system-id fs-0123456789abcdef0 \
--query 'MountTargets[].[MountTargetId,AvailabilityZoneName,IpAddress,LifeCycleState]' --output table
timeout 5 bash -c '</dev/tcp/10.0.1.24/2049' && echo "2049 reachable" || echo "2049 not reachable"Then find the line you see in this list and open its fix:
- 1The mount target's security group has no inbound NFS rule from the instance
The TCP test to port 2049 hangs, and the mount target's security group lists no TCP 2049 rule for the instance's group or subnet - 2The instance's own security group no longer allows outbound 2049
The mount target's inbound rule is in place, but the instance's security group has custom outbound rules and none covers TCP 2049 - 3A custom network ACL blocks NFS or its return traffic
Both security groups look right, the instance and the mount target sit in different subnets, and at least one of those subnets uses a custom network ACL - 4The mount command points at an IP address that is not a live mount target
The IP in the mount command or /etc/fstab does not appear in describe-mount-targets, or belongs to a mount target that is not available
What does the error look like?
mount.nfs: Connection timed outsudo mount -t nfs ... hangs for a minute or two before it fails
Cause 1 of 4
The mount target's security group has no inbound NFS rule from the instance
You seeThe TCP test to port 2049 hangs, and the mount target's security group lists no TCP 2049 rule for the instance's group or subnet
Check
The mount hangs and ends in mount.nfs: Connection timed out when the security group on the mount target drops the instance's NFS traffic. EFS needs an inbound TCP 2049 rule on the mount target, with the EC2 instance's security group (or its address range) as the source. Mount targets use no other inbound port and ignore their outbound rules.
aws efs describe-mount-target-security-groups --mount-target-id fsmt-0123456789abcdef0
aws ec2 describe-security-groups --group-ids sg-0aaaaaaaaaaaaaaaa \
--query 'SecurityGroups[].IpPermissions[?ToPort==`2049`]'Fix
Add the inbound rule to the mount target's security group, naming the instance's security group as the source rather than a wide CIDR.
aws ec2 authorize-security-group-ingress --group-id sg-0aaaaaaaaaaaaaaaa \
--protocol tcp --port 2049 --source-group sg-0bbbbbbbbbbbbbbbbVerify
The TCP test prints 2049 reachable and the mount returns within seconds.
timeout 5 bash -c '</dev/tcp/10.0.1.24/2049' && echo "2049 reachable"
sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.0.1.24:/ /mnt/efsConfirmed by docs.aws.amazon.com
Cause 2 of 4
The instance's own security group no longer allows outbound 2049
You seeThe mount target's inbound rule is in place, but the instance's security group has custom outbound rules and none covers TCP 2049
Check
Every security group starts with an allow-all egress rule, so this only bites after someone swapped that rule for a short allow list. EFS then times out because the instance may not open the connection to the mount target on 2049 in the first place.
aws ec2 describe-security-groups --group-ids sg-0bbbbbbbbbbbbbbbb --query 'SecurityGroups[].IpPermissionsEgress'Fix
Add an outbound TCP 2049 rule from the instance's group to the mount target's group.
aws ec2 authorize-security-group-egress --group-id sg-0bbbbbbbbbbbbbbbb \
--ip-permissions 'IpProtocol=tcp,FromPort=2049,ToPort=2049,UserIdGroupPairs=[{GroupId=sg-0aaaaaaaaaaaaaaaa}]'Verify
The /dev/tcp test reaches 2049 and the file system mounts.
timeout 5 bash -c '</dev/tcp/10.0.1.24/2049' && echo "2049 reachable"Confirmed by docs.aws.amazon.com
Cause 3 of 4
A custom network ACL blocks NFS or its return traffic
You seeBoth security groups look right, the instance and the mount target sit in different subnets, and at least one of those subnets uses a custom network ACL
Check
When the client reaches a mount target in another subnet, the network ACLs of both subnets must let TCP 2049 through and let the replies come back. ACLs are stateless, so an allow rule in one direction does not cover the answer, and a custom ACL denies anything that matches no numbered rule.
aws ec2 describe-network-acls --filters Name=association.subnet-id,Values=subnet-0ccccccccccccccc0 \
--query 'NetworkAcls[].Entries[].[RuleNumber,Egress,Protocol,PortRange.From,PortRange.To,CidrBlock,RuleAction]' --output tableFix
On the mount target's subnet ACL, allow TCP 2049 in from the client subnet and the ephemeral range out to it; mirror that on the client's subnet ACL (2049 out, ephemeral ports in).
aws ec2 create-network-acl-entry --network-acl-id acl-0ddddddddddddddd0 --ingress \
--rule-number 110 --protocol tcp --port-range From=2049,To=2049 \
--cidr-block 10.0.2.0/24 --rule-action allow
aws ec2 create-network-acl-entry --network-acl-id acl-0ddddddddddddddd0 --egress \
--rule-number 110 --protocol tcp --port-range From=1024,To=65535 \
--cidr-block 10.0.2.0/24 --rule-action allowVerify
The port test passes from the client subnet and the mount succeeds.
timeout 5 bash -c '</dev/tcp/10.0.1.24/2049' && echo "2049 reachable"Confirmed by docs.aws.amazon.com
Cause 4 of 4
The mount command points at an IP address that is not a live mount target
You seeThe IP in the mount command or /etc/fstab does not appear in describe-mount-targets, or belongs to a mount target that is not available
Check
If the address you mount is wrong and nothing at that address rejects the request, the client waits and times out exactly as if a firewall dropped it. An fstab line that still holds the address of a deleted mount target is one way to get there.
grep -i nfs /etc/fstab
aws efs describe-mount-targets --file-system-id fs-0123456789abcdef0 \
--query 'MountTargets[?LifeCycleState==`available`].IpAddress'Fix
Use the IP of an available mount target from describe-mount-targets, or mount by the file system DNS name. The DNS name needs a mount target in the instance's Availability Zone and a VPC with DNS hostnames turned on that uses the Amazon-provided DNS server.
sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport \
fs-0123456789abcdef0.efs.us-east-1.amazonaws.com:/ /mnt/efsVerify
findmnt shows the EFS file system mounted on /mnt/efs.
findmnt /mnt/efsConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Create one security group for EFS mount targets that allows TCP 2049 only from the application's security group, and attach it to every mount target.
- Mount by file system DNS name or with the EFS mount helper instead of hard-coding mount target IPs in /etc/fstab, and keep _netdev on every fstab entry.
- Run the five-second /dev/tcp test on port 2049 in the instance's boot or deploy health check, so a blocked port shows up before the app needs the files.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro, Raheeb, Loade Driver.