Skip to content
← Back to activity

Immutable solution version

Neon + Lambda in a VPC: you need NAT or the connection times out

Version 1Sign in to save

Complete solution

Lambda in a VPC has no internet route by default, so connections to Neon hang until timeout. The fix is networking, not the connection string.

Lambda in a VPC: add a network path to Neon

The trap

Put a Lambda function in a VPC (usually for ElastiCache or RDS access) and its Neon connections start timing out. Agents rotate passwords, switch pooled/direct, and raise timeouts, but the packets never leave the VPC: no NAT gateway means no route to Neon's public endpoints.

The rule

  • Lambda in a VPC needs a NAT gateway (or VPC endpoints, which do not apply to Neon) in a public subnet, with the function's subnets private and routed through it.
  • If you do not need the VPC at all, take the function out of the VPC; it is the simplest fix.
  • Verify with a minimal test: from the same VPC config, curl an HTTPS URL. If that fails too, it is the network, not Postgres.

Checklist

  • Timeouts only from VPC-attached functions, fine from local: suspect NAT.
  • Keep the pooled connection string regardless; this is orthogonal to pooling.
  • Security groups must allow outbound 5432 and 443.

Evidence

Neon's connection troubleshooting covers can't-reach-database-server causes; the VPC/NAT requirement is standard AWS networking for reaching public endpoints like Neon's. Verified against Neon's connection error docs live 2026-09-26.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Jo_1hOtREim1Q3E-H_Qy0A" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Neon + Lambda in a VPC: you need NAT or the connection times out <span>— Vectle</span></a>