Not able to access Phoenix server from different machines in the network

Hi!

I use Phoenix to serve an API and I’ve been using it in development for many months now running it on port 4000 and a Node server (SSR React) on port 3000 that sends request to the Phoenix backend.

I noticed yesterday I was not being able to access the Phoenix server from other computers in the same network anymore but, oddly enough, the Node server is working normally. On the machine that runs the server I can access it normally (both using locahost and the local IP).

Things I tried:

  1. Changing the port 4000 to other 4 digit numbers.
  2. Run servers from different projects (new and existing ones) to compare what was different in terms of configuration—turns out I’m not able to access any Phoenix server from other machines anymore.
  3. Delete mix.lock, run mix deps.clean --all
  4. Explicity set http: [ip: {0, 0, 0, 0}, port: 4000] on endpoint config on config/dev.exs

I’m not at all versed on computer networks so any ideas on how to troubleshoot it would be very appreciated :slight_smile:

You might provide more informations…

  1. What happened yesterday? Did You upgrade?
  2. What kind of development is it? Releases?

Are you running in dev mode while in production?

1 Like

Hi, thanks for your reply!

I’ve been thinking of it and I can’t think of anything I’ve done differently yesterday… but it could be that it’s been like this for longer than I realized; I use accessing the server from different devices to test on mobile/tablet and I haven’t done that in while (perhaps a week). But I don’t think I upgraded anything.

What is odd to me is that this is happening across different Phoenix projects (different Phoenix versions, using different Elixir versions even). At first I though it could have been some config or library I changed, but since it’s happening to all projects past and present I’m assuming it’s not?

Btw, another thing I did try was to swap to a previous Elixir version (I’m using 1.14 and tried different 1.13 and 1.12 versions I still have on asdf)

It’s just the server you get with mix phx.server

No, :prod in production and :dev in development!

Did you check your computer’s firewall?

2 Likes

Omg.

Screenshot 2022-10-03 at 10.13.52

This is embarrassing :grimacing:
But… as someone that knows nothing about networks, I’m confident to say I never came anywhere near these settings section. Is this something that programs can just change on your behalf?
Also, is it normal for the same application to have 4 entries there?

Thank you for showing the way :slight_smile:

macOS asks you when you first start a new application (or maybe when it first tries to bind to a socket?) if you want to allow or block incoming connections.

Those are probably not the same application in the OS’s PoV. Maybe the same or different BEAM instance but run from different folders with different arguments. But I’m no macOS firewall expert.

2 Likes

Time for me to do some reading :sweat_smile:

Thank you again!