Rails 5 WebSockets “Request origin not allowed” [Solution]

Since I have spent about 15 minutes today trying to figure out why my WebSockets are not updating in development, I have decided to put quick fix here, hopefully this will be useful.

Issue:

Anatoly Spektor

Let me help you!

Hey, I am Anatoly, founder of this blog. I would love to help you! I have 6+ years experience in Web Development and IT Leadership. Lets work together on your project! Leave me your email and I will schedule a FREE Consultation!

When I started ActionCable I got this error:

Request origin not allowed: http://0.0.0.0:3000
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2016-08-01 14:23:38 -0700

Solution:

  1.  Go to
    development.rb
  2.  Add following line:
    config.action_cable.allowed_request_origins = ['http://0.0.0.0:3000']
  3. Restart Web Server
  4. Enjoy!

Click Subscribe to stay tuned for some cool Rails 5 ActionCable examples!

Cheers,

Anatoly

Thanks for installing the Bottom of every post plugin by Corey Salzano. Contact me if you need custom WordPress plugins or website design.

Anatoly Spektor

IT Consultant with 6 years experience in Software Development and IT Leadership. Participated in such projects as Eclipse IDE, Big Blue Button, Toronto 2015 Panam Games.

Related Posts

Join the Discussion

Your email address will not be published. Required fields are marked *

Discussion

  1. […] have create separate post how to resolve it ,but for your convenience, I will repeat it […]

  2. Bruno Wego

    Thank you very much, exactly what I needed.

  3. Michal

    Great Job. You just saved my time 🙂

arrow