Rails - Is your app listening on

So, I turned my app into an API-only one, and I’m trying to deploy it as a new app.
After many errors solved, I’m blocked at this one:

error.message="instance refused connection. is your app listening on make sure it is not only listening o
n (hint: look at your startup logs, servers often print the address they are listening on)" 2024-07-05T15:21:
55Z proxy[4d8901e2c01738] cdg [error]request.method="GET" request.id="01J21QS0KNDBR013T8YM1NB6GZ-c

My app is (allegedly) successfully deployed after running fly deploy, but navigating to the URL shows nothing. While, instead, running fly logs show that error.

When I passed

    HOSTNAME = “”

in my fly.toml file, nothing changed.

Same when adding ENV HOSTNAME "" in my Dockerfile.

For reference, I will share my fly.toml and Dockerfile files:

# fly.toml app configuration file generated for metrakapi on 2024-07-05T15:38:37+01:00
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.

app = 'metrakapi'
primary_region = 'cdg'
console_command = '/rails/bin/rails console'


  release_command = './bin/rails db:prepare'

  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ['app']

    port = 3000
    type = 'http'
    interval = '10s'
    timeout = '2s'
    grace_period = '5s'
    method = 'GET'
    path = '/up'
    protocol = 'http'
    tls_skip_verify = false

      X-Forwarded-Proto = 'https'

  size = 'shared-cpu-1x'
  memory = 512
  swap_size_mb = 512

  guest_path = '/rails/public'
  url_prefix = '/'
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile

LABEL fly_launch_runtime="rails"

# Rails app lives here
WORKDIR /rails

# Set production environment
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development:test" \

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler

# Install packages needed to build gems
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential libpq-dev

# Install application gems
COPY --link Gemfile Gemfile.lock ./
RUN bundle install && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git

# Copy application code
COPY --link . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl postgresql-client && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
    useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
    chown -R 1000:1000 db log storage tmp
USER 1000:1000

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
CMD ["./bin/rails", "server"]

When I looked again at the logs, without trying to access the app, I realised the error was different as you can see here.

With the main line being:

Errno::EACCES: Permission denied @ dir_s_mkdir - /rails/public/assets (Errno::EACCES)

So, I’ve updated my Dockerfile by adding permission to that folder:

# Create the public/assets directory
RUN mkdir -p public/assets

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
    useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
    chown -R 1000:1000 db log storage tmp public/assets
USER 1000:1000

And that solved the issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.