`InvalidSubnet.Conflict: The CIDR '10.0.1.0/24' conflicts with another subnet` when creating a subnet.
BeginnerTroubleshootingVPC and Connectivity
Answer
Likely causes → The CIDR overlaps an existing subnet in the same VPC. A related error, InvalidSubnet.Range: The CIDR '10.1.0.0/24' is invalid, means the block is outside the VPC CIDR(s) or smaller than /28.
Diagnose →
aws ec2 describe-vpcs --vpc-ids vpc-0abc --query 'Vpcs[].CidrBlockAssociationSet[].CidrBlock'
aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0abc \
--query 'Subnets[].[SubnetId,CidrBlock,AvailabilityZone]' --output table
Fix →
- Pick a free, non-overlapping range inside the VPC CIDR
- If the VPC is full, add a secondary CIDR:
aws ec2 associate-vpc-cidr-block --vpc-id vpc-0abc --cidr-block 10.1.0.0/16 - Then create the subnet inside the new range
Prevent → Plan subnets with IPAM or a documented CIDR map. Calculate subnets in Terraform with cidrsubnet() rather than typing them by hand.
More on VPC and Connectivity
`ssh: connect to host 3.250.1.1 port 22: Connection timed out`. Walk the checks.Beginner`ssh: connect to host ... port 22: Connection refused`. How is it different from a timeout?Beginner`Permission denied (publickey)` on a new EC2 instance.IntermediatePrivate instances cannot reach the internet; `curl: (28) Connection timed out after 10000 milliseconds`.IntermediateNAT gateway shows `ErrorPortAllocation` in CloudWatch and connections drop.IntermediateVPC peering is `active` but ping fails.Intermediate