When I launch a server with a security group that allows all traffic into my private subnet, it displays a warning that it may be open to the world.

If it is a private subnet, how can that be?

  • 6
    It means that if you were to add an EIP to the instance and the default route were an IGW it would be accessible from the world. The SG would not block the access. Commented Nov 20, 2013 at 20:31
  • A subnet being "public" or "private" is not a simple attribute check, but rather a high-level description of the subnet based on its routes. AWS probably can't run a comprehensive accessibility check (or it doesn't want to), so it gives a general warning instead
    – Mike B
    Commented Jul 6, 2022 at 0:19

5 Answers 5


The main difference is the route for in the associated route table.

A private subnet sets that route to a NAT gateway/instance. Private subnet instances only need a private ip and internet traffic is routed through the NAT in the public subnet. You could also have no route to to make it a truly private subnet with no internet access in or out.

A public subnet routes through an Internet Gateway (igw). Instances in a public subnet require public IPs to talk to the internet.

The warning appears even for private subnets, but the instance is only accessible inside your vpc.

  • 2
    what makes it so that the instance is only accessible inside your vpc? if i put an instance in a private subnet, what's stopping traffic from outside the vpc to reach it. I saw that by default the vpc network acl permits all traffic Commented May 29, 2019 at 22:25
  • 5
    @committedandroider - External traffic can only reach the instance if: It has a public IP assigned, it is on a subnet with the default route for pointed at an internet gateway (aka 'public subnet'), the assigned security group allows the incoming traffic on the specified port from, and if the network ACLs allow the ip/port. If ANY of these are not set correctly, public traffic will not reach the instance. Commented May 30, 2019 at 3:06
  • 1
    thanks @JasonFloyd this is still helpful 3 years later!
    – Randy L
    Commented Jul 15, 2022 at 17:20
  • The host behind NAT still counts on 'public' subnet: If a subnet is associated with a route table that has a route to an internet gateway, it's known as a public subnet. If a subnet is associated with a route table that does not have a route to an internet gateway, it's known as a private subnet. docs.aws.amazon.com/vpc/latest/userguide/… Commented Apr 23 at 16:42
  • @EugenKonkov - There's no direct incoming public route to a host on a private subnet and it does not have a public IP assigned. It only can reach out of its own network via the NAT host/device on a public subnet. Commented Apr 27 at 21:15

The Topic of this question is different from the actual problem which is described above. This topic is also important and highly searched over the Internet, and just because of this, other websites have much higher views of the same topic as it is not well defined here, if both Public and Private Subnets can go To the Internet to download updates and packages then what is the difference between them? Both should be Public then, but let me clear this and add my answer from AWS point of view, as well as a conceptual, practical point of view.

Answer of the Topic:

Public and Private Subnets are the name of the concept, not actually a separate entity.

Answer of the Actual Problem which is being asked

The warning is Correct technically, I am assuming you are talking about Inbound Traffic, not Outbound, because if you wanted to download software, packages, updates so you have to add every single IP in the Outbound which is practically not good and time consuming., so, the warning is about other networks and Private classes

For example: if you are adding a rule in Private Subnet security group like Inbound so it doesn't mean that it is available for Public and someone can send a request to that Instance/service/machine, what actually it means that other Private Subnets or Private networks can communicate with your instance or services, like 192.168.x.x, 172.16.x.x, Private classes, which is only possible if your routes are allowed to do that. Other than this, you can ignore that warning and not worry about it. Here you have to understand the difference between From the Internet and To the Internet, so as per Security Group rules and help info, it will show you that warning which can be misunderstood by anyone.

The Confusion

When you create a Subnet in AWS VPC, there is an option Auto-assign Public IPv4 This is the main problem which makes confusion to the people if it is set to Yes, then your Subnet is Public, no matter what name or key-value you tagged to the Subnet, which means, at the time of Subnet creation, if you use a name like Private Subnet-A so it doesn't mean its Private Subnet, it depends on your use case and configurations (Auto-assign Public IP option).

Difference between Public and Private Subnet:

Instances in Public Subnet can be accessible From the Internet, which means traffic From the Internet can hit a machine/Instance/Service in Public Subnet. You normally keep things like Load Balancers, Web Servers in Public Subnet. So when you create them, you add name Public in front of them to keep them separate from others and, it doesn't matter you enabled Auto-assign Public IPv4, but every time you choose the Public Subnet that you marked Public, you have to check or enable Auto-assign Public IPv4 option when you launch an instance of EC2 or RDS/Service. But it's better if you enable Auto-assign Public IPv4 at Subnet level to make it properly Public because this is the reason you are making difference and using Public-Private concept, so whenever you launch any service/Instance/machine in Public Subnet, it will be able to accessible From the Internet and To the Internet, means, You can hit the service/Instance over the Internet and can download updates and packages in the service/Instance as well. You can check who is going To the Internet by simply typing the command curl wgetIP.com, you will see your Instance/machine Public IP in results.

"Because, when you launch an instance into a Subnet that has this attribute enabled, a Public IP address is assigned to the primary network interface (eth0) that's created for the instance. A Public IP address is mapped to the primary Private IP address through network address translation (NAT).".....said, AWS.

Instances in Private Subnet can not be accessible From the Internet. E.g. you can put Database Server, Redis Server or these kinds of other services in a Private Subnet and no one can access it From the Internet. It would be accessible only via Instances/machines/Services in Public Subnet (Web server, ELB, etc). Because it doesn't have Public IP enabled option and also we marked it as Private for the specific use as explain, for security and unwanted access over the Internet. This is good for architecture level security to avoid loopholes. To access this Private Subnet services/Instances, you have to add allow rule in Security group and add proper routes in the route table.

Now the question is,

Can Private Subnet go To the Internet?

So, answer is by default no,
If you wanted to access To the Internet through a Private Subnet or a Subnet having no Public IP or a Subnet having disabled Auto-assign Public IPv4, you need to create NAT instance or a NAT-gateway, and that NAT-gateway must have Public IP so, your service/Instance with Private IP will go to the Internet and can download updates,software and packages. Private IP will route traffic to NAT-gateway and NAT-gateway will route to Internet Gateway. Then your communication from Private Subnets to Internet can start, you can check your IP by simply running command curl wgetIP.com, it will give you NAT-gateway Public IP, because NAT-gateway will go to the Internet for you and Internet gateway is a path of outside communication to the world and its a term in networking as well to pass the traffic from inbound to outbound. You can simply understand its main gate of the building for the exit.

Conclusion The instances in the public subnet can send outbound traffic directly to the Internet, whereas the instances in the private subnet can't. Instead, the instances in the private subnet can access the Internet by using a network address translation (NAT) gateway that resides in the public subnet. The database servers can connect to the Internet for software updates using the NAT gateway, but the Internet cannot establish connections to the database servers.".....said, AWS


Internet Access: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html

VPC & Subnets Basics: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html

VPC with Public and Private Subnets (NAT): https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html

  • Great answer. Thank you.
    – Hephaestus
    Commented Oct 20, 2020 at 22:28

As documented here

PUBLIC SUBNET If a subnet's traffic is routed to an internet gateway, the subnet is known as a public subnet. PRIVATE SUBNETIf a subnet doesn't have a route to the internet gateway, the subnet is known as a private subnet.

And also this is documented here.


The distinction between "public" and "private" subnets in AWS VPC is determined only by whether the subnet has an Internet Gateway (IGW) attached to it. From the AWS docs:

If a subnet is associated with a route table that has a route to an internet gateway, it's known as a public subnet. If a subnet is associated with a route table that does not have a route to an internet gateway, it's known as a private subnet.

The IGW allows network traffic from the internet to reach endpoints inside the subnet.

To answer your second question:

When I launch a server with a security group that allows all traffic into my private subnet, it displays a warning that it may be open to the world. If it is a private subnet, how can that be?

It appears AWS does not check whether your chosen subnet has a route table with an IGW or not, when displaying that warning. It's a blanket warning they always show when you set up an instance with a security group allowlisting all inbound traffic. They use "may be" (as opposed to "will be") in there to cover their butts, but the warning is only relevant if you are on a public subnet.

  • This is the most succinct answer. I was looking for confirmation that a subnet is a subnet. It's what you do with it that makes it private/public. Thanks!
    – bitofagoob
    Commented Apr 21 at 11:07
  • Does this mean that attached NAT makes private subnet as a public (As determined by AWS). Commented Apr 23 at 16:56
  • A NAT Gateway doesn’t make your subnet public. However an Internet Gateway (IGW) would do.
    – geepster
    Commented Apr 24 at 18:43

The problem we are trying to solve is to make some resources "private", that is deny inbound traffic from outside your VPC, but still allow those private resouces to access the internet for e.g. updates.

There are a couple of ways to do this:

  • You could try to use Network Access Control Lists (NACL) but these affect inbound- and outbound traffic the same way ("stateless"). Therefore, you cannot deny inbound traffic while allowing outbound traffic. Also, they seem to be rarely recommended anyhow (see second comment of this SO post).
  • You could use security groups associated with each resource. This would work well but seems the less popular solution (maybe because it's easy to forget adding a security group to a resource?)
  • At last, you could setup a separate subnet without a connection to the internet gateway but instead a connection to a NAT gateway. That NAT gateway is usually (always?!) placed in another subnet which has a connection to the internet gateway. You'd then call these two subnets private and public, respectively. In other words, the terms "private subnet" and "public subnet" are really just names for this specific setup (as the other posts here state) and do not describe an inherent feature of the subnet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .