Private networking not working for cron job
davidjconnolly
HOBBYOP

3 months ago

I've got a Next.js/Node app that's working great. However, I have a cron service that boots up, sleeps for 3 seconds then runs a curl command to an API endpoint on my server. I'm using my internal URL, however it doesn't work no matter what I try. Any suggestions?

Solved$10 Bounty

Pinned Solution

davidjconnolly
HOBBYOP

3 months ago

Ha! I figured it out, I had to hard code the port to 3000. For whatever reason the public API automatically uses the right port but the internal port gets set to 80 which the API isn't listening on.

6 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


3 months ago

Can you screenshot the private networking portion of Frank?


davidjconnolly
HOBBYOP

3 months ago

For sure! Here you go @samgordon:

Attachments


3 months ago

Can you share the entire deployment logs as well? Private networking looks correct.


davidjconnolly
HOBBYOP

3 months ago

Yea I've been through all the obvious stuff and it works fine with the public URL.

Here are the deploy logs for the cron service:

[Region: us-east4]

=========================

Using Detected Dockerfile

=========================

context: 46sv-QsrM

internal

load build definition from Dockerfile

0ms

internal

load metadata for docker.io/library/alpine:latest

132ms

auth

library/alpine:pull token for registry-1.docker.io

0ms

internal

load .dockerignore

0ms

1

FROM docker.io/library/alpine:latest@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412 cached

5ms

2

RUN apk add --no-cache curl

1s

OK: 12 MiB in 25 packages

importing to docker

48ms

auth

sharing credentials for production-us-east4-eqdc4a.railway-registry.com

0ms

Build time: 9.46 seconds

Here are the logs for frank:
Starting Container

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "railway", schema "public" at "pgvector.railway.internal:5432"

27 migrations found in prisma/migrations

No pending migrations to apply.

npm notice

npm notice New patch version of npm available! 11.6.2 -> 11.6.3

npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.6.3

npm notice To update run: npm install -g npm@11.6.3

npm notice

warning emoji WARNING: Found migrations in database but not in code:

- 20251115212417_add_ai_provider_name_and_is_global

- 20251115212522_add_selected_embedding_model_to_frank_settings

- 20251115212719_add_primary_to_calendars

- 20251115213204_add_archived_at_to_frank_conversations

- 20251115214204_add_global_search_settings

- 20251115214427_add_frank_message_observability_fields

- 20251116130232_add_agent_run_step_observability_fields

- 20251117021711_add_task_archived_and_templates

This can cause ordering issues. Consider cleaning up orphaned migrations.

These might be from deleted branches or manual database changes.

white_check_mark emoji All 27 code migrations are properly recorded in the database.

(8 orphaned migrations in DB are not critical but should be reviewed)

> frankapp@1.0.0 start

> next start

▲ Next.js 15.5.6

- Local: http://localhost:3000

- Network: http://10.152.216.114:3000

✓ Starting...

✓ Ready in 395ms

The Cron Job itself is literally just a Dockerfile:

FROM alpine:latest

# Install curl
RUN apk add --no-cache curl

# Add delay for network readiness, then make the request
CMD ["sh", "-c", "sleep 3 && echo \"Calling: $APP_URL/api/cron/calendar-sync\" && curl -X POST $APP_URL/api/cron/calendar-sync -H \"Authorization: Bearer $CRON_SECRET\" -H \"Content-Type: application/json\" && echo \"\nRequest completed with exit code: $?\" || (echo \"\nRequest failed with exit code: $?\" && exit 1)"]

davidjconnolly
HOBBYOP

3 months ago

Ha! I figured it out, I had to hard code the port to 3000. For whatever reason the public API automatically uses the right port but the internal port gets set to 80 which the API isn't listening on.


Status changed to Solved noahd 3 months ago


Loading...