Blog
3 min read

IPv4 vs IPv6: What's the Difference and Does It Matter for Your App?

IPv4 addresses look like 203.0.113.7; IPv6 addresses look like 2001:db8::1. Why the internet ran out of IPv4, what IPv6 changes, A vs AAAA DNS records, and the practical things app builders need to check — like listening on both and firewalls.

Every device on the internet needs an IP address so other devices can reach it. There are two versions in use side by side: IPv4 and IPv6.

IPv4: the original

An IPv4 address is four numbers from 0 to 255, separated by dots:

203.0.113.7

That's 32 bits, which allows about 4.3 billion addresses. In the 1980s that seemed endless. Today there are far more devices than that — phones, laptops, TVs, servers, light bulbs — and the free pool of IPv4 addresses ran out years ago. Addresses are now bought and sold, which is why some cloud providers charge extra for a public IPv4 address.

The internet coped mainly with NAT (network address translation): your home router has one public IPv4 address, and every device behind it shares it using private addresses like 192.168.1.20.

IPv6: the replacement

An IPv6 address is eight groups of hexadecimal digits, separated by colons:

2001:0db8:0000:0000:0000:0000:0000:0001

Runs of zeros can be shortened with ::, so that's written 2001:db8::1.

IPv6 uses 128 bits — about 340 undecillion addresses (a 39-digit number). Every device can have its own public address; there's no shortage to work around.

Side by side

IPv4 IPv6
Example 203.0.113.7 2001:db8::1
Size 32 bits 128 bits
Available addresses ~4.3 billion Effectively unlimited
DNS record A AAAA
Localhost 127.0.0.1 ::1
"All interfaces" 0.0.0.0 ::
In a URL with a port http://203.0.113.7:3000 http://[2001:db8::1]:3000

Does it matter for your app?

Mostly it just works — browsers try both and use whichever connects. But a few things trip people up.

DNS: A and AAAA records

An A record points a name to an IPv4 address; an AAAA record points to an IPv6 address. You can have both. (DNS records explained)

If you add an AAAA record, make sure your server actually serves your site over IPv6 — otherwise visitors on IPv6 networks (many mobile networks) get errors while it works fine for you.

Listening on both

When your app or web server listens on 0.0.0.0, that's IPv4 only on some systems. Listening on :: usually covers both (depending on OS settings). If the site works over IPv4 but not IPv6, check what your app or Nginx is listening on. (What is localhost?)

"localhost" can mean ::1

On some systems localhost resolves to ::1 (IPv6) first. If your database or app only listens on 127.0.0.1, connecting to "localhost" can fail with ECONNREFUSED. Using 127.0.0.1 explicitly is a common fix. (ECONNREFUSED explained)

Firewalls

Firewall rules are often separate for IPv4 and IPv6. A port you closed on IPv4 might be open on IPv6. Tools like UFW handle both if IPv6 is enabled in their config. (UFW firewall basics)

Server pricing

Some providers include an IPv6 address free and charge for IPv4. An IPv6-only server is cheaper, but some visitors and services still can't reach IPv6-only addresses. For a public website, you still want IPv4 — or a proxy like Cloudflare in front that accepts both. (What is Cloudflare?)

The summary

  • IPv4 = 4.3 billion addresses, ran out, stretched with NAT.
  • IPv6 = practically unlimited, longer addresses, AAAA records.
  • Both run side by side; browsers pick whichever works.
  • Check AAAA records, listening addresses and firewall rules cover what you intend.

EasySpawn runs your app on its own server with the networking, domain and HTTPS set up for you, so you don't have to untangle A records and listening addresses yourself. See how it works or join the waitlist.

Related: What Is an IP Address and a Port? · What Is a DNS Server? · DNS Records Explained · What Is a Server?

Keep reading