NullOranje

NullOranje

I’m trying to setup a Vagrant box using generic/freebsd12 as the base image. I cannot get my Phoenix application to listen on IPv4 addresses inside the VM. It will respond to IPv6 as expected, so I know it works.

config :bison_app, BisonWeb.Endpoint,
  http: [
    port: String.to_integer(System.get_env("PORT") || "4000")
  ],
  url: [host: System.get_env("HOST") || "app.local"],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: secret_key_base

From inside the VM:

$ curl -4 localhost:4000
curl: (7) Failed to connect to localhost port 4000: Connection refused

$ curl -6 localhost:4000
<HTML response>

Showing Posts 1 to 6

jarmo

jarmo

I have the same problem on FreeBSD 13.2. Same code/configuration listens on IPv4 on Ubuntu.

Did you solve it somehow in the end?

zaljir

zaljir

Try adding the explicit IP to listen on? Not sure what the defaults are.

E.g.:

  config :my_app, MyWeb.Endpoint,
    url: [host: host, port: 443, scheme: "https"],
    http: [
      ip: {0, 0, 0, 0},
      port: port
    ],

jarmo

jarmo

Managed to solve it. I’m in the process of migrating from Ubuntu Linux to FreeBSD and for some reason on Ubuntu Linux Phoenix did bind to the IPv4, but using the same code and configuration on FreeBSD did bind only on IPv6.

I tried all tricks on changing config/config.exs, config/prod.exs and config/prod.secret.exs, but it turned out that the problem was in the lib/my_app_web/endpoint.ex where in init function had the following line:

{:ok, Keyword.put(config, :http, [:inet6, port: port])}

Changing it to:

{:ok, Keyword.put(config, :http, [:inet, port: port])}

I’m pretty sure that this line has been on inet6 for the entire time of the project and it was generated by phx.new at the time of project creation. Just bear in mind that this is a legacy Phoenix application running version 1.5.1 and might not have the same generated file when creating a new Phoenix application today.

bortzmeyer

bortzmeyer

On Linux, by default, an “inet6” socket also accepts IPv4 (you can disable that with the sysctl option net.ipv6.bindv6only or by adding {ipv6_v6only: true} to your socket options). On FreeBSD, it is not the case by default. You can enable a similar behaviour by adding ipv6_ipv4mapping=YES in /etc/rc.conf. See rc.conf(5)

drfreeze

drfreeze

I’m on 14.1 and can’t get it to bind to tcp4.

$ doas netstat -an | grep LISTEN
tcp6 0 0 *.4000 . LISTEN

I have also set ipv4 mapping in rc.conf.

rc.conf

ipv6_ipv4mapping=“YES”

$ uname -a
FreeBSD learning01 14.1-RELEASE-p5 FreeBSD 14.1-RELEASE-p5 GENERIC amd64

Any ideas?

jarmo

jarmo

This problem even persists on FreeBSD 14 when applying the changes in endpoint.ex as described above by me?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews