Hello!
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 0.0.0.0:3000? make sure it is not only listening o
n 127.0.0.1 (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
[env]
HOSTNAME = “0.0.0.0”
in my fly.toml
file, nothing changed.
Same when adding ENV HOSTNAME "0.0.0.0"
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'
[build]
[deploy]
release_command = './bin/rails db:prepare'
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 1
processes = ['app']
[checks]
[checks.status]
port = 3000
type = 'http'
interval = '10s'
timeout = '2s'
grace_period = '5s'
method = 'GET'
path = '/up'
protocol = 'http'
tls_skip_verify = false
[checks.status.headers]
X-Forwarded-Proto = 'https'
[[vm]]
size = 'shared-cpu-1x'
memory = 512
swap_size_mb = 512
[[statics]]
guest_path = '/rails/public'
url_prefix = '/'
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.0
FROM ruby:$RUBY_VERSION-slim
LABEL fly_launch_runtime="rails"
# Rails app lives here
WORKDIR /rails
# Set production environment
ENV BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development:test" \
RAILS_ENV="production"
# 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
EXPOSE 3000
CMD ["./bin/rails", "server"]