Bad Request (400)

I’m attempting a python/django site and can’t get past this error.

Here’s some background:

  • I’m porting this site from Heroku, the code itself is good.
  • The machine starts up, but doesn’t seem accessible from outside, thus “Bad Request (400)” from browser.
  • I’ve connected to the instance using “fly ssh console” and run a “wget http://localhost:8000” this produces and index.html file that indicates the site is running at port 8000.
  • Running a “wget http://localhost” or “wget https://localhost” produces a “failed: Connection refused.” on each port (80 and 443, respectively)

From what I can tell, the site is running fine internally, but is not getting exposed externally.
My fly.toml looks like this:

# fly.toml file generated for wishlists on 2022-10-09T17:14:42-06:00

app = "wishlists"
kill_signal = "SIGINT"
kill_timeout = 5
#processes = []

[deploy]
  release_command = "python manage.py migrate"

#[env]
#  DEBUG = true

#[experimental]
#  allowed_public_ports = []
#  auto_rollback = true

[[services]]
#  http_checks = []
  internal_port = 8000
#  processes = ["app"]
  protocol = "tcp"
#  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
#    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443
 
  [[services.tcp_checks]]
 #   grace_period = "1s"
 #   interval = "15s"
 #   restart_limit = 0
 #   timeout = "2s"
    interval = 10000
    timeout = 2000

#  [[services.http_checks]]
#    interval = 10000
#    grace_period = "20s"
#    method = "get"
#    path = "/"
#    protocol = "http"
#    timeout = 2000
#    tls_skip_verify = false
#    [services.http_checks.headers]

#[[statics]]
#  guest_path = "/app/public"
#  url_prefix = "/static/"

Just looked at your app.

We do not return an HTML page when we return a 400. So that seems to be happening within your instance, not from our proxy.

Do you have anything looking for a specific hostname that might return a 400 if it doesn’t match? (or if it’s not localhost)

Thanks! Super useful response! That’s the nudge in the right direction I needed. I thought for sure it was fly producing the 400. Once that was sorted it was easy to fix. thx!