🌐My IP Address 🔌Port Checker 🔍DNS Lookup 📋WHOIS Lookup 🔒SSL Checker 🗺️IP Location Map 📡HTTP Headers ⚡Latency Test 🖥️User Agent 🔢IPv6 Detector
AWS EC2 · Security Groups

Allow your IP in an AWS Security Group

Your public IP is detected below and dropped into every command, so you can open SSH, RDP or a database port to yourself — and only yourself — from the console, the AWS CLI or Terraform.

Your rule, pre-filled
Detected from your browser: this is the address AWS sees when you connect from this network. Replace sg-0123456789abcdef0 with your group ID and 22 with your port.
Your public IPv4 address
Detecting…
CIDR:—
1
Add the inbound rule
AWS CLI · SSH on port 22
AWS CLI
aws ec2 authorize-security-group-ingress \
  --group-id sg-0123456789abcdef0 \
  --protocol tcp \
  --port 22 \
  --cidr YOUR_IP/32
2
Check that it is there
Lists every rule of the group, with its rule ID
AWS CLI
aws ec2 describe-security-group-rules \
  --filters Name=group-id,Values=sg-0123456789abcdef0
3
Remove it when you are done
Or when your IP changes, before adding the new one
AWS CLI
aws ec2 revoke-security-group-ingress \
  --group-id sg-0123456789abcdef0 \
  --protocol tcp \
  --port 22 \
  --cidr YOUR_IP/32
ℹ️
On Windows, the trailing \ only works in Git Bash or WSL. In PowerShell end each line with a backtick (`); in CMD use ^, or put the whole command on one line.

What this rule actually does

A security group is a virtual firewall attached to an instance's network interface. Everything inbound is denied until a rule allows it, and each rule is a protocol, a port range and a source. The source 203.0.113.42/32 means "exactly this one IPv4 address": the /32 says that all 32 bits of the address must match, so nobody else on the internet gets in.

Security groups are stateful. When your SSH session is allowed in, the replies are allowed back out automatically, so you do not need an outbound rule for it — and a new group's default outbound rule already allows all traffic. That is why "allow my IP" is a single inbound rule.

Option 1: add it in the AWS console

  1. Open the EC2 console and choose Security Groups in the left navigation, under Network & Security.
  2. Select the group attached to your instance. If you are not sure which one it is, open the instance and look at its Security tab.
  3. On the Inbound rules tab, choose Edit inbound rules, then Add rule.
  4. For Type, pick the service (SSH, RDP, PostgreSQL…) or Custom TCP with your port.
  5. For Source, choose My IP. The console fills in the public IPv4 address of your computer.
  6. Add a description that says who and when — for example fernando-laptop 2026-10-28 — and choose Save rules.

The console's My IP and the address at the top of this page should match. If they don't, your browser and your SSH client may leave through different networks — a VPN with split tunnelling, a corporate proxy or two internet connections — and the rule has to use the address of the network your SSH client actually uses.

Option 2: add it with the AWS CLI

The command in the card above is the short form. If you don't know the group ID, ask for the groups attached to the instance:

AWS CLI
aws ec2 describe-instance-attribute \
  --instance-id i-0123456789abcdef0 \
  --attribute groupSet

The short form cannot carry a description. To leave one — so that the next person knows whose address it is — use --ip-permissions:

AWS CLI
aws ec2 authorize-security-group-ingress \
  --group-id sg-0123456789abcdef0 \
  --ip-permissions 'IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=YOUR_IP/32,Description=fernando-laptop}]'

Two errors are worth recognising. InvalidPermission.Duplicate means the rule already exists, so there is nothing to add. RulesPerSecurityGroupLimitExceeded means the group is full: by default a security group holds 60 inbound rules for IPv4 and another 60 for IPv6. The quota can be raised, but a full group is usually a sign that old addresses were never removed.

Home and mobile connections change their public IP from time to time, and the old rule keeps pointing at an address that is no longer yours. When that happens, run the revoke command with the old address and the add command with the new one. This page always shows the address you have now.

Option 3: manage it with Terraform

For new code, the AWS provider recommends one aws_vpc_security_group_ingress_rule resource per rule, instead of the older aws_security_group_rule resource or ingress blocks inside aws_security_group. Mixing those styles on the same group can make Terraform overwrite rules or show changes on every plan.

Terraform HCL
resource "aws_vpc_security_group_ingress_rule" "ssh_from_my_ip" {
  security_group_id = aws_security_group.app.id
  cidr_ipv4         = "YOUR_IP/32"
  ip_protocol       = "tcp"
  from_port         = 22
  to_port           = 22
  description       = "SSH from my laptop"
}

If your IP changes often, don't hard-code it: declare a my_ip variable, use cidr_ipv4 = "${var.my_ip}/32" and pass the current address with terraform apply -var="my_ip=YOUR_IP". The plan then shows a change to that one rule, which is easy to review.

Which port goes in the rule

Open only the port of the service you are reaching. Opening "All traffic" to your IP works, but it also exposes every port you forgot was listening.

PortServiceNotes
22SSH / SFTPLinux instances. Bots scan it constantly.
3389RDPWindows instances. Never open it to 0.0.0.0/0.
5432PostgreSQLFor RDS, the rule goes in the security group attached to the DB instance, and the instance must be set as publicly accessible.
3306MySQL / MariaDB / Aurora MySQLSame as PostgreSQL: the database's own security group.
27017MongoDB (self-hosted)MongoDB Atlas uses its own IP access list, not an AWS security group.
443 / 8080HTTPS / app serversOnly while the service is private or in testing; public web servers allow everyone on 80 and 443.

Still can't connect? Work through this list

A security group that drops your traffic does it silently, so every failure looks the same: a timeout. Check these in order:

  1. The rule is in the wrong group. An instance can have several security groups; the rule must be in one of the groups attached to the network interface you connect to.
  2. Your address is not the one in the rule. Compare the rule with the IP at the top of this page. VPNs, mobile hotspots and office networks each have their own public address.
  3. You are connecting over IPv6. If your computer and the instance both have IPv6, the client may prefer it and an IPv4 rule won't match. Add an IPv6 rule with /128 (a single address) or connect to the IPv4 address. The IPv6 detector shows whether you have one.
  4. The instance has no public route. It needs a public IPv4 address (or an Elastic IP) and a subnet whose route table sends 0.0.0.0/0 to an internet gateway.
  5. A network ACL blocks the way. Network ACLs are stateless and sit at the subnet level: they need an inbound rule for your port and an outbound rule for the return traffic on ephemeral ports.
  6. The server's own firewall drops it. UFW, firewalld or the Windows firewall on the instance still have the last word.
  7. Nothing listens on that port, or it listens only on localhost. Run sudo ss -tlnp on the instance. Databases often bind to 127.0.0.1 until you change their configuration.

To test from your side, use nc -zv YOUR_INSTANCE_IP 22 or Test-NetConnection YOUR_INSTANCE_IP -Port 22 in PowerShell. Browsers can't test SSH at all; for HTTPS and most database ports the port checker works from the browser.

Keep it tight

The IP whitelist generator writes the same rule for MongoDB Atlas, Google Cloud, UFW, iptables and nginx, with your address already filled in.

AWS security group questions

Usually yes. Both read the public IPv4 address your browser's traffic comes from. They differ only when your browser and your SSH or database client leave through different networks, for example with a split-tunnel VPN or a corporate proxy. The rule must use the address of the network your client uses.
No. Security groups are stateful: the responses to traffic you allowed in are allowed back out regardless of the outbound rules. Network ACLs are different — they are stateless, so if you have customised them you need both directions there.
By default, 60 inbound rules for IPv4 and 60 for IPv6, and each single address is one rule. The quota can be increased, and a network interface can use up to 5 security groups by default. For long lists of addresses, a managed prefix list is easier to maintain than individual rules.
Most likely your public IP changed. Home and mobile connections are reassigned addresses periodically, and the rule still allows the old one. Remove the old rule and add your current address; this page detects it each time you open it.
It is far safer than opening it to everyone, because only connections from your address reach the SSH server. Keep password login disabled and use keys. If you can, avoid the open port altogether with Session Manager, which needs no inbound rule.
Copied!