lmletham

lmletham

Deploy to Fly.io using custom domain not working?

Hey guys!

I have deployed my Phoenix project to Fly here and set up my DNS records and certs in order to connect to my custom domain here but something is broken.

The fly.dev url works perfectly, but even though my custom domain displays my test text it also throws a “Something went wrong” error..

Fly.io logs say this:

[error] Could not check origin for Phoenix.Socket transport.
[info] Origin of the request: https://wordsmith.pub
[info] This happens when you are attempting a socket connection to
[info] a different host than the one configured in your config/
[info] files. For example, in development the host is configured
[info] to “localhost” but you may be trying to access it from
[info] “127.0.0.1”. To fix this issue, you may either:
[info] 1. update [url: [host: …]] to your actual host in the
[info] config file for your current environment (recommended)
[info] 2. pass the :check_origin option when configuring your
[info] endpoint or when configuring the transport in your
[info] UserSocket module, explicitly outlining which origins
[info] are allowed:
[info] check_origin: [“https://example.com”,
[info] “//another.com:888”, “//other.com”]

I tried to do step 1 by changing the config.exs file in my Phoenix project to add url: [host: "wordsmith.pub"], but that didn’t fix anything and I don’t know how to do the second suggestion.

I didn’t see any documentation on Fly indicating I would have to change my Phoenix files in order to deploy to a custom domain, so I’m not sure what to try next.

My first thought is that this is some kind of DNS record propagation issue. I added the certs and DNS records pointing to the custom domain yesterday morning. So let me know if I simply need to wait longer!

Thanks!

Marked As Solved

lmletham

lmletham

I was too hasty in calling it solved!

Changing the PHX_HOST variable to “Wordsmith.pub” definitely fixed by custom domain, but at the cost of breaking the “wordsmith-lml.fly.dev” one.

I was able to get the fly.dev one back working though by adding your check origin suggestion.

In my Phoenix Project, config/config.exs file I added both URLs:

config :wordsmith, WordsmithWeb.Endpoint,
  url: [host: "localhost"],
  check_origin: ["https://wordsmith.pub","https://wordsmith-lml.fly.dev"],
  adapter: Bandit.PhoenixAdapter,
  render_errors: [
    formats: [html: WordsmithWeb.ErrorHTML, json: WordsmithWeb.ErrorJSON],
    layout: false
  ],
  pubsub_server: Wordsmith.PubSub,
  live_view: [signing_salt: "E1HLgpGK"]

So the current state is:

  • PHX_HOST variable in the fly.toml file is set to “wordsmith.pub”
  • I added both URLs to a check origin line.

Let me know if that is totally unkosher! It seems to be working.

Last Post!

natewallis

natewallis

I thought using @ for CNAME wasn’t a good idea since that stops you creating other records on the apex. Maybe there instructions have changed since this was last posted as it seems the advice now is to point A and AAAA to the ipv4 and ipv6 addresses respectively and then use a CNAME for www to point to the fly dev address..

Where Next?

Trending in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
tj0
I’ve been following the steps here for the upgrade from 1.6 to 1.7 and it has gone relatively smoothly all the way till the phoenix_view ...
New
cgraham
Hi! What is currently the best library/method for parsing text and tabular data out of PDF files in Elixir or Erlang?
New
stefanchrobot
Hi, I need a way to handle data migrations in my application. I found an article by @wojtekmach about manual migrations: Automatic and ma...
New
stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
Squid Mesh is an open source workflow automation runtime for Elixir applications. It is aimed at Phoenix and OTP apps that want to defin...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

We're in Beta

About us Mission Statement