Error connecting to Redis on localhost


(Watercolor Games) #1

I’m aware there’s probably tons and tons of topics already discussing these sorts of problems but after hours of googling I have yet to find anything meaningful or helpful for my issue.

I have set up a Discourse instance on an Azure VM running Ubuntu 16.04 LTS, following the official setup guide on the Discourse github.

I have configured SMTP in the app.yml file so that I am connecting to in-v3.mailjet.com on port 587 with TLS on, and I have correctly specified my API key/secret (username/password) as shown in the mailjet dashboard. Using these settings from my development system I was able to send myself a test email and receive it, however using them on the Discourse instance and sending the admin verification email, I did not receive it.

Discourse seems to not report any errors in the web UI, and I’m not sure if it writes anything about this to a logfile or where to access it. I have tried all open SMTP ports on Mailjet:

  • 25
  • 465
  • 587
  • 2525

to no avail. I have even tried them both with and without TLS. However trying ALL ports with/without TLS from my development system I am able to get my test email.

I’m aware that Azure doesn’t allow outgoing SMTP mail directly from a VM which is why I am using Mailjet.

I have checked my Mailjet dashboard and no emails have even been detected as being received by the server from my Discourse however from my development environment they all went through.

Also on the server I tried running a python3.5 interpreter with the following code

import smtplib

s = smtplib.SMTP("in-v3.mailjet.com", 25)

and no errors were thrown, which shows it is in fact connecting to the server. I also tried this for port 2525.

Any suggestions would be greatly appreciated.


(Dean Taylor) #2

There is a whole troubleshooting check list here to start with:

Specifically check the logs as mentioned there… you might want to check /logs on your install too.


(Watercolor Games) #3

Just validated my app.yml - everything was okay except for the fact there were double-quotes around the password. Not sure if that caused the issue (syntax error possibly?) so I deleted them and rebuilt the app.

Using Telnet I verified that in-v3.mailjet.com:2525 is in fact accessible from the server.

So, as far as Discourse logs go, I used tail to view the last few lines in the discourse log, and these were what I saw.

Processing by FinishInstallationController#register as */*
  Rendering finish_installation/register.html.erb within layouts/finish_installation
  Rendered finish_installation/register.html.erb within layouts/finish_installation (2.0ms)
  Rendered common/_special_font_face.html.erb (0.1ms)
  Rendered layouts/_head.html.erb (1.9ms)
Completed 200 OK in 13ms (Views: 5.0ms)
Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) subscribe failed, reconnecting in 1 second. Call stack ["/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:345:in `rescue in establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:331:in `establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:134:in `block in call_loop'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:280:in `with_socket_timeout'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:133:in `call_loop'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/subscribe.rb:43:in `subscription'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/subscribe.rb:12:in `subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:2765:in `_subscription'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:2143:in `block in subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'", "/usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:2142:in `subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:303:in `global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:516:in `global_subscribe_thread'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:464:in `block in new_subscriber_thread'"]
Job exception: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)

Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) subscribe failed, reconnecting in 1 second. Call stack ["/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:345:in `rescue in establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:331:in `establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:862:in `block in get'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'", "/usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:861:in `get'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:251:in `process_global_backlog'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:287:in `block in global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:300:in `global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:516:in `global_subscribe_thread'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:464:in `block in new_subscriber_thread'"]

As you can see there are some connection refused errors while connecting to Redis, but I don’t see how this would affect mail transfer (then again I have absolutely no clue what Redis actually is or what it does.)


(Watercolor Games) #4

All troubleshooting steps performed. Emails still are not being sent by Discourse.


(Dean Taylor) #5

Following the official guide you shouldn’t be seeing Redis connection errors as it’s running on the same server as both web and DB instance.

Try restarting your Azure instance and sending a test mail and checking the logs immediately.


(Jeff Atwood) #6

You have a broken install. Redis isn’t working.


(Watercolor Games) #7

@DeanMarkTaylor And how will I send a test email from Discourse when I can’t even get my admin account activated to be able to access the ACP?

@codinghorror And what shall I do to fix this?


(Dean Taylor) #8

There are ways around this - plenty of threads if searched…
… however…

Because:

  1. your installation looks broken
  2. and you don’t have any existing data to worry about (because it looks like you are starting your first install)

…the simplest thing to do would be to create a new VM instance and see if you run into the same trouble again following the instructions here:

discourse/INSTALL-cloud.md at master · discourse/discourse · GitHub

Are these the instructions you followed?


(Watercolor Games) #9

Those are the EXACT instructions I followed. The only thing that could’ve broken it could be the fact that I got disconnected from ssh mid-install because of an internet outage at home, but I was running the install through a screen so disconnecting from SSH wouldn’t end the install, in fact, it didn’t end it.

Also I rebooted the VM and had it send me my activation email once again then immediately looked in the logs and saw this:

root@wcgames-primary:/var/discourse# tail shared/standalone/log/rails/production.log
Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) subscribe failed, reconnecting in 1 second. Call stack ["/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:345:in `rescue in establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:331:in `establish_connection'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:862:in `block in get'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'", "/usr/local/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.3/lib/redis.rb:861:in `get'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:251:in `process_global_backlog'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:287:in `block in global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus/backends/redis.rb:300:in `global_subscribe'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:516:in `global_subscribe_thread'", "/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/message_bus-2.0.6/lib/message_bus.rb:464:in `block in new_subscriber_thread'"]
Started PUT "/finish-installation/resend-email" for 67.193.17.104 at 2017-09-30 01:54:50 +0000
Processing by FinishInstallationController#resend_email as HTML
  Parameters: {"authenticity_token"=>"JMi51ZKXl8dtqsjrS1FbKTZ/+ApwDoec9mOYXll9EGtstaq5vy+M0RsLAJZutpY8rtwTVgxXd98yJlWanhvvbg=="}
  Rendering finish_installation/resend_email.html.erb within layouts/finish_installation
  Rendered finish_installation/resend_email.html.erb within layouts/finish_installation (0.7ms)
  Rendered common/_special_font_face.html.erb (0.7ms)
  Rendered layouts/_head.html.erb (18.0ms)
Completed 200 OK in 220ms (Views: 40.1ms | ActiveRecord: 10.0ms)
Sent mail to theplexgate@gmail.com (244.0ms)
root@wcgames-primary:/var/discourse#

It has attempted to send the email to me but I have not received it yet.


(Dean Taylor) #10

As @codinghorror already mentioned Redis isn’t working…

… I would go with a reinstall / new instance, it’s easier time wise than fighting with a broken install at this stage.


(Watercolor Games) #11

So do you want me to just back up my app.yml, nuke the /var/discourse folder, reclone, readd the app.yml and then ./launcher rebuild app?


(Kane York) #12

No, we mean destroy the entire VM, and start over. It’s less likely that you accidentally left some Docker layers in a bad state or something equally obscure that way.


(Watercolor Games) #13

@riking Alright, just did that. I set up the install using the same setup procedure as before, and had it send my admin activation email. I didn’t receive it yet.

I did end up being thrown out of ssh mid-install because my internet connection is horrid at home, so I ran ./discourse-setup again with no error.

I did check the log after sending admin activation email and saw this:

root@wcgames-primary:/var/discourse# tail shared/standalone/log/rails/production.log
Started GET "/site/basic-info.json" for 64.71.168.196 at 2017-09-30 13:28:48 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 1ms (Views: 0.2ms)
Started GET "/site/basic-info.json" for 64.71.168.196 at 2017-09-30 13:28:48 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
Job exception: Unsupported argument type: -1 (Fixnum)

Job exception: Unsupported argument type: -2 (Fixnum)

root@wcgames-primary:/var/discourse#

No Redis errors, but I do see some job exceptions regarding an unsupported argument type for something.

Not really sure what to do next. The game I’m hosting this discourse instance for is supposed to launch as a prealpha today so I need to get this install working.


(Watercolor Games) #14

UPDATE: Okay this is not a Discourse issue anymore. My Mailjet just got terminated. Come on… I’m having the worst luck ever. I need to find a different way to send emails out from discourse without having to have my home address sent in the email or anything stupid like that.


(Watercolor Games) #15

Update: Nope, clearly I’m too tired for this because I signed into my OLD mailjet account which I terminated myself over a year ago. Damnit. Maybe it still is a discourse issue.


(Watercolor Games) #16

God damn, creating subsequent replies like this to update feels really janky. I can’t find an ‘edit’ button so… [shrugs]

Anyway signed into my ACTUAL mailjet and thank god it isn’t terminated, but also no emails from the new discourse install went through. I had it resend the activation email and looked at the log, and according to discourse everything went through just fine. Haven’t checked my email inbox though but judging by the fact it said this before and I never got an email, I don’t think there’ll be one.


(Jay Pfaffman) #17

Click the … Icon and you’ll see the pencil.

It’s still almost certainly a problem with mailjet.


(Watercolor Games) #18

Curse my eyes. That ‘…’ icon blends into the background so much I probably never would’ve found it on my own :stuck_out_tongue:

Anyway, what would be my next troubleshooting step? Given that I can send emails through mailjet from my home PC using a script and using the exact same config I use for discourse, I don’t see how this would be a mailjet issue.

Update:

So I noticed every time the /finish-install/confirm-email action is visited, I get this in the log:

Job exception: Unsupported argument type: -1 (Fixnum)

directly after “Completed 200 OK”.

Could this have any information leading to the original issue with SMTP?

Update 2

Issue is a mailjet issue. Turns out Mailjet IS getting requests from my server but the sender email is set to noreply@wcgames-primary5442.cloudapp.net which isn’t recognized by the Mailjet servers.

The only fixes would be to either:

  1. Make Discourse send mail setting the From header to the DISCOURSE_DEVELOPER_EMAIL, only for my instance.
  2. Activate the unrecognized domain from Mailjet. This is impossible without making it so my server can RECEIVE email or at least forward it to my gmail.

So… the easiest would be option 1, but I wouldn’t know how to do that.


(Dean Taylor) #19

During the install what are you answering to the following question?
Hostname for your Discourse? [discourse.example.com]:

If it’s wcgames-primary5442.cloudapp.net that’s where you are going wrong by the sounds of it, this should be the actual user facing domain name you want to use.


(Watercolor Games) #20

Issue status: Fixed.

I was able to validate the server hostname on mailjet by temporarily shutting off the discourse docker instance, and running an apache instance and added a temp file that mailjet could look for to validate the fact I own the server. After doing that, SMTP worked perfectly. The site’s now live.