Skip to content

Serverless deploy to LocalStack fails: “Invalid character in header content [authorization]” #273

@BuhayovA

Description

@BuhayovA

Running serverless deploy --stage local against LocalStack aborts during the “Resolving AWS account ID” step with the error:

Unable to find function cleanup on plugin Esbuild
Deploying "sls" to stage "local" (us-east-1)
Using serverless-localstack
Using serverless-localstack
serverless-localstack: Reconfigured endpoints

Error: Failed to resolve AWS account ID: Invalid character in header content ["authorization"]

deployment never reaches packaging or CloudFormation synthesis

serverless.ts

plugins: ['serverless-iam-roles-per-function', 'serverless-localstack'],

custom:
  localstack:
    stages: ['local']
    edgePort: 4566
    host: 'http://localhost'

provider:
  name: aws
  runtime: nodejs22.x
  environment:
    AWS_ENDPOINT_URL: 'http://localhost:4566'
    AWS_ACCESS_KEY_ID: '000000000001'
    AWS_ACCOUNT_ID: '000000000001'

docker-compose.yml

  s3mock:
    image: adobe/s3mock:latest
    environment:
      - retainFilesOnExit=true
      - root=root
    ports:
      - 9090:9090
    volumes:
      - ./uploadedFiles:/root

  localstack:
    container_name: localstack
    image: localstack/localstack
    ports:
      - 4566:4566
      - 4510-4559:4510-4559
    environment:
      - DEBUG=${DEBUG:-0}
      - SERVICES=lambda,sqs,sns
    volumes:
      - '${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

Versions

Component Version
Serverless Framework 4.14.3
serverless-localstack 1.3.1
LocalStack Docker image localstack/localstack:latest (pulled 2025-05-14)
Node.js 22.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions