You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS EC2实例DNS配置变更后出现Stripe连接错误求助

Fixing getaddrinfo EAI_AGAIN api.stripe.com:443 After AWS DNS Adjustments

Hey there, let's tackle this connection error you're seeing with Stripe after AWS modified your DNS settings. That EAI_AGAIN error is a clear sign your EC2 instance is failing to resolve the api.stripe.com domain via DNS—here's how to diagnose and fix it step by step:

Step 1: Verify DNS Resolution on Your EC2 Instance

First, log into your EC2 server and run these commands to test if DNS is working for Stripe's endpoint:

# Test with nslookup
nslookup api.stripe.com

# Or use dig for more detailed output
dig api.stripe.com

If either command times out or returns no valid IP addresses, your DNS configuration is definitely the problem. If it does return IPs, skip to Step 4 to check network connectivity.

Step 2: Check Your EC2 Instance's DNS Config

Take a look at the DNS servers your instance is using by viewing the /etc/resolv.conf file:

cat /etc/resolv.conf

For AWS EC2 instances in a VPC, this should typically list AWS's default DNS server (usually your VPC CIDR block's second IP, e.g., 10.0.0.2 for a 10.0.0.0/16 VPC) or any custom DNS servers you've configured. If you see unfamiliar nameservers, that might be the root issue.

Step 3: Validate VPC DHCP Options Set

Since AWS adjusted your DNS settings, head to the AWS Console and check your VPC's DHCP Options Set:

  • Go to VPC Dashboard > DHCP Options Sets
  • Select the DHCP set attached to your VPC
  • Confirm the Domain name servers field is set to either:
    • AmazonProvidedDNS (AWS's default, which handles external domain resolution)
    • A valid custom DNS server that can resolve public domains like api.stripe.com
      If this was altered during the AWS DNS adjustment, revert it to your correct, pre-existing configuration.

Step 4: Test Network Connectivity (If DNS Works)

If DNS resolves successfully but you still get the error, test if your instance can reach Stripe's API directly:

curl -v https://api.stripe.com

If this times out or fails, check your EC2 security groups and network ACLs to ensure outbound HTTPS (port 443) traffic is allowed to the internet.

Temporary Workaround (For Urgent Cases)

If you need a quick fix while resolving the DNS issue, manually add api.stripe.com to your instance's /etc/hosts file:

  1. First, look up Stripe's API IPs from a working machine (e.g., your local computer using nslookup api.stripe.com)
  2. Edit the hosts file on your EC2 instance:
sudo nano /etc/hosts
  1. Add a line like this (replace the IP with one you found):
18.215.138.247 api.stripe.com

Note: This is a temporary band-aid—Stripe's IPs can change, so you'll want to get your DNS configuration working properly long-term.


内容的提问来源于stack exchange,提问作者King RV

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 10:23:15