4 months ago
I'm trying to integrate the backend of my AstroJS (astro api serve-side backend) application with a Python backend service, both in the same project. When I use the public backend address, the call works; when I use the internal address, a fetch error occurs. I've tried several recommendations, but nothing works. Both applications were deployed via GitHub and a Dockerfile.
Below are some configurations.
Front end:
export default defineConfig({
adapter: node({
mode: 'standalone',
}),
vite: {
plugins: [tailwindcss()],
},
integrations: [react()],
site: process.env.SITE_URL || 'http://localhost:8080',
output: 'server',
compressHTML: true,
server: {
port: 8080,
host: '::',
open: '/',
},astro dockefile
# Build stage
FROM node:20-alpine AS builder
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
ARG APP_ENV
ARG SITE_URL
ENV APP_ENV=${APP_ENV}
ENV SITE_URL=${SITE_URL}
# Copy project files
COPY . .
#
# Build the project
RUN pnpm build
# Runtime stage
FROM node:20-alpine AS runner
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install only production dependencies
RUN pnpm install --prod --frozen-lockfile --ignore-scripts
# Copy built assets from builder
COPY --from=builder /app/dist ./dist
# Expose port
EXPOSE 8080
# Start the preview server
CMD ["sh", "-c", "PORT=8080 node dist/server/entry.mjs"]
Backend dockefile
# services/auth_users_service/Dockerfile
FROM python:3.11-slim
WORKDIR /app
# Instalar dependências do sistema
RUN apt-get update && apt-get install -y \
gcc \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
# Instalar Poetry
RUN pip install poetry
# Configurar Poetry para não criar virtual env
RUN poetry config virtualenvs.create false
RUN poetry config virtualenvs.in-project false
# Copiar arquivos de configuração
COPY pyproject.toml /app
COPY poetry.lock* /app
# Instalar dependências Python (comando atualizado)
RUN poetry install --only=main --no-interaction --no-ansi --no-root
RUN apt-get update && apt-get install -y iputils-ping
# Copiar código da aplicação
COPY . /app
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]Attachments
Pinned Solution
4 months ago
Guys, I've founded the solution from my issue. Actually I've changed the commands in Dockerfile at service backend python
Before:
CMD ["uvicorn", "app.main:app", "--host", "::", "--port", "8000"]Now:
CMD ["hypercorn", "app.main:app", "--bind", "[::]:8000"]The error was due the incapacity to unvicorn handles with IPV6 connections.
6 Replies
4 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 NextJS App trouble with backend fetch when server side rendering
🧵 ECONNREFUSED Error when accessing Astro server api endpoint
🧵 Unable to call service using internal name within a project
If you find the answer from one of these, please let us know by solving the thread!
4 months ago
FRONTEND BUILDLOGS (astro api serve-side backend)
Nov 6, 2025, 10:51 AM
[Region: us-east4]
=========================
Using Detected Dockerfile
=========================
context: kfl3-CYpF
internal
load build definition from Dockerfile
0ms
internal
load metadata for docker.io/library/node:20-alpine
125ms
auth
library/node:pull token for registry-1.docker.io
0ms
internal
load .dockerignore
0ms
builder
7ms
internal
load build context
0ms
builder
RUN pnpm install --frozen-lockfile cached
0ms
builder
COPY package.json pnpm-lock.yaml ./ cached
0ms
builder
WORKDIR /app cached
0ms
builder
RUN corepack enable && corepack prepare pnpm@latest --activate cached
0ms
builder
COPY . .
27ms
builder
RUN pnpm build
17s
13:52:24 [build] Complete!
hPVNbYWcuY2hhckF0KDApXTtpZihhYSl7YWk9YWcubWF0Y2goYWFbMV0pO2FwPWFhWzBdfWVsc2V7Zm9yKHZhciBhbz0wO2FvPFg7Kythbyl7YWE9VFthb107YWk9YWcubWF0Y2goYWFbMV0pO2lmKGFpKXthcD1hYVswXTticmVha319aWYoIWFpKXthcD1GfX1hbT1hcC5sZW5ndGg+PTUmJiJsYW5nLSI9PT1hcC5zdWJzdHJpbmcoMCw1KTtpZihhbSYmIShhaSYmdHlwZW9mIGFpWzFdPT09InN0cmluZyIpKXthbT1mYWxzZTthcD1KfWlmKCFhbSl7YWpbYWddPWFwfX12YXIgYWI9YWY7YWYrPWFnLmxlbmd0aDtpZighYW0pe2FkLnB1c2goWSthYixhcCk=","timestamp":"2025-11-06T13:52:15.577892369Z"}]}
runner
RUN pnpm install --prod --frozen-lockfile --ignore-scripts cached
0ms
runner
COPY --from=builder /app/dist ./dist
104ms
auth
sharing credentials for production-us-east4-eqdc4a.railway-registry.com
4 months ago
FRONTEND (astro api serve-side backend) DEPLOY LOGS and HTTP logs
{"message":"Starting Container","attributes":{"level":"info"},"timestamp":"2025-11-06T13:53:33.000000000Z"}
{"message":"13:53:33 [@astrojs/node] Server listening on ","attributes":{"level":"info"},"timestamp":"2025-11-06T13:53:35.051080689Z"}{"message":" local: http://localhost:8080 \t","attributes":{"level":"info"},"timestamp":"2025-11-06T13:53:35.051098563Z"}{"message":" network: http://10.250.12.213:8080","attributes":{"level":"info"},"timestamp":"2025-11-06T13:53:35.051105152Z"}{"message":"","attributes":{"level":"info"},"timestamp":"2025-11-06T13:53:35.051111620Z"}{"message":"[HEALTH_TEST] Tentando acessar: http://auth_users_service.railway.internal:8000/health","attributes":{"level":"info"},"timestamp":"2025-11-06T13:55:26.248256992Z"}{"message":"","attributes":{"email":"polako.rafa@gmail.com","endpoint":"/api/auth/signup","env":"develop","error":{"message":"fetch failed","name":"TypeError","stack":"TypeError: fetch failed\n at node:internal/deps/undici/undici:13510:13\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async SignupService.sendOTPcode (file:///app/dist/server/chunks/signup-service_El12sk1R.mjs:12:22)\n at async Module.POST (file:///app/dist/server/pages/api/auth/signup.astro.mjs:28:5)\n at async renderEndpoint (file:///app/dist/server/chunks/astro/server_CexPlqos.mjs:587:18)\n at async lastNext (file:///app/dist/server/chunks/index_CjM7nEZF.mjs:2592:23)\n at async file:///app/dist/server/chunks/_@astrojs-ssr-adapter_CP6ao_xt.mjs:64:22\n at async callMiddleware (file:///app/dist/server/chunks/index_CjM7nEZF.mjs:1354:10)\n at async RenderContext.render (file:///app/dist/server/chunks/index_CjM7nEZF.mjs:2639:22)\n at async NodeApp.render (file:///app/dist/server/chunks/_@astrojs-ssr-adapter_CP6ao_xt.mjs:915:18)"},"level":"error","service":"auth","timestamp":"2025-11-06T14:00:20.440Z"},"timestamp":"2025-11-06T14:00:29.474577050Z"}{"message":"AUTH_SERVICE http://auth_users_service.railway.internal:8000","attributes":{"level":"info"},"timestamp":"2025-11-06T14:00:29.474608126Z"}requestId:
"24oCM5IJQiqT3HLrg4a9AQ"
timestamp:
"2025-11-06T14:00:20.463362538Z"
method:
"POST"
path:
"/api/auth/signup"
host:
httpStatus:
500
upstreamProto:
"HTTP/1.1"
downstreamProto:
"HTTP/2.0"
responseDetails:
""
totalDuration:
81
upstreamAddress:
"http://[fd12:d46e:7aa5:0:a000:24:a49:d2c7]:8080"
clientUa:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"
upstreamRqDuration:
81
txBytes:
42
rxBytes:
891
srcIp:
"189.121.203.6"
edgeRegion:
"us-east4-eqdc4a"
upstreamErrors:
""
4 months ago
Hi,
You'll need to use the public IP for all frontend components. Your frontend cannot access the internal network.
samgordon
Hi,You'll need to use the public IP for all frontend components. Your frontend cannot access the internal network.
4 months ago
It's actually backend because the calls are made via the Astro API (server-side).
4 months ago
Guys, I've founded the solution from my issue. Actually I've changed the commands in Dockerfile at service backend python
Before:
CMD ["uvicorn", "app.main:app", "--host", "::", "--port", "8000"]Now:
CMD ["hypercorn", "app.main:app", "--bind", "[::]:8000"]The error was due the incapacity to unvicorn handles with IPV6 connections.
Status changed to Solved noahd • 4 months ago

