Skip to main content

Question on ActionCable Group Chat part 4, development.rb fix for redis

General • Asked by Rob Sturcke

Saw in the comments the fix for (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) however I added the following to my development.rb:

  config.action_cable.allowed_request_origins = ['http://localhost:3000/']

Is that correct or should I be going to the following when I launch rails s:

redis://localhost:6379/1

(Sorry if this was already answered)


Yep, that'll work fine. You don't have to worry about the redis url at all for that. This is a validation to make sure that the browser origin (the domain that attempted to connect to the websocket) is an allowed one.

Basically you don't want someone on another website stealing your chat messages from another site, so this is a protection built-in for that.

It should default to allow localhost:3000, but it seems people are having trouble with that. Your solution is correct, and you'll add to that when you deploy it to production. 👍


Yeah I keep getting the error even after restarting rails s showing up though even with my line is now just config.action_cable.allowed_request_origins

.rvm/gems/ruby-2.3.0/gems/redis-3.3.1/lib/redis/client.rb:345:in `rescue in establish_connection': Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)

Your redis server isn't running. If you installed it with homebrew, you can type brew info redis to see the instructions on starting it up again.


Got ya! Didn't realize I had to install it through brew.


Yeah, it's now the default for Rails I believe, so it's a required dependency if you use the defaults. Super easy install with homebrew and everything should be automatically working for you after that.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.