sabri

sabri

Failed to start child: Phoenix.PubSub.PG2

I am trying to have two EndPoint in the phoenix app, but I get this error when starting the server:

** (Mix) Could not start application myapp: MayApp.start(:normal, []) returned an error: shutdown: failed to start child: MayApp.Schools.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2
        ** (EXIT) already started: #PID<0.393.0>

Here is the children supervisors,

children = [
      # Start the endpoint when the application starts
      supervisor(MayApp.Endpoint, []),
      
      # Start the endpoint for schools
      supervisor(MayApp.Schools.Endpoint, []),

      # Start the Ecto repository
      supervisor(MayApp.Repo, []),
      # Here you could define other workers and supervisors as children
      # worker(MayApp.SomeWorker, [], name: SomeWorker),
    ]

MayApp.Schools.Endpoint is a copy of MayApp.Endpoint only socket "/socket" is pointing to another module.

Any idea?

Marked As Solved

chrismccord

chrismccord

Creator of Phoenix

Your endpoint starts the pubsub server based on the endpoint configuration. So you need to configure only one of those endpoints to start the pubsub server, and the other one can simply be configured to use the registered pubsub name of the other. For example:

config :my_app, MyApp.Enpdpoint1,
  pubsub: [name: MyApp.PubSub, adapter: Phoenix.PubSub.PG2]

...
config :my_app, MyApp.Enpdpoint2,
  pubsub: [name: MyApp.PubSub]

Also Liked

Cyb3rKid

Cyb3rKid

For anyone in the future searching for solutions, before you change your endpoints. After experiencing the same error today, it took a surprisingly easier solution.
All I did was →

mix deps.clean --all
mix deps.get

Then the application was able to start without any issues.

sabri

sabri

Thanks

MarkMekhaiel

MarkMekhaiel

You just saved my bacon, thanks for sharing this

Where Next?

Popular in Questions Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53578 245
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52238 488
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vegabook
I'm brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
nobody
Hi! In PHP: $SERVER['SERVERADDR'] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement