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

LocalStack访问/_localstack/ses获取SES邮件返回404问题咨询

LocalStack SES内置检索API返回404问题解决

问题背景

根据LocalStack官方文档说明:

已发送的消息可通过服务API端点(GET /_localstack/ses)或文件系统两种方式检索获取。
消息同时会保存至数据目录(DATA_DIR,可参考配置说明),若未配置数据目录,则使用临时目录(TMPDIR)存储。文件以JSON格式保存在ses/子目录下,按消息ID分类组织。

实际使用时该API端点无法正常访问,文档未标注使用细节与监听端口,访问默认服务端口4566对应地址http://localhost:4566/_localstack/ses/仅返回404状态码。目前已确认邮件正常写入data_dir目录,需要通过API方式获取邮件内容。

复现环境

  • LocalStack版本:0.14.3.3
  • 启动方式:docker-compose、CLI启动均复现问题
  • 复现操作与报错信息:
~ localstack --version
0.14.3.3
~ SERVICES=ses localstack start -d

     __                     _______ __             __
    / /   ____  _________ _/ / ___// /_____ ______/ /__
   / /   / __ \/ ___/ __ `/ /\__ \/ __/ __ `/ ___/ //_/
  / /___/ /_/ / /__/ /_/ / /___/ / /_/ /_/ / /__/ ,<
 /_____/\____/\___/\__,_/_//____/\__/\__,_/\___/_/|_|

 💻 LocalStack CLI 0.14.3.3

[17:02:56] starting LocalStack in Docker mode 🐳
[17:02:57] preparing environment
           configuring container
           starting container
[17:02:58] detaching

~ aws --endpoint-url http://localhost:4566 ses verify-email-identity --email-address abc@mail.com
~ aws --endpoint-url http://localhost:4566 ses send-email --destination ToAddresses=abc@test.com --message file://$HOME/tmp/message.json --from abc@mail.com
{
    "MessageId": "eorislettxoexeoc-xdcvrgnw-zggi-exmm-dfcc-dllwqdlnrrlu-thowhk"
}
~ curl -v http://localhost:4566/_localstack/ses/
*   Trying ::1:4566...
* connect to ::1 port 4566 failed: Connection refused
*   Trying 127.0.0.1:4566...
* Connected to localhost (127.0.0.1) port 4566 (#0)
> GET /_localstack/ses/ HTTP/1.1
> Host: localhost:4566
> User-Agent: curl/7.77.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404
...

解决方案

0.14.3属于较早的Legacy版本,该版本的内部诊断端点默认未挂载到4566端口的新版网关上,按以下任意一种方式处理即可正常调用:

  • 方案一(兼容当前版本):启动LocalStack时添加环境变量LEGACY_EDGE_ROUTES=1,访问时去掉路径末尾的斜杠,直接请求http://localhost:4566/_localstack/ses即可拿到所有已发送邮件的JSON列表,示例命令:
    LEGACY_EDGE_ROUTES=1 SERVICES=ses localstack start -d
    curl http://localhost:4566/_localstack/ses
    
  • 方案二(推荐):升级LocalStack到1.0及以上正式版本,无需额外配置,直接请求http://localhost:4566/_localstack/ses即可正常返回结果,新版本同时支持按MessageId查询单封邮件的接口GET /_localstack/ses/messages/{message_id}。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 14:21:08