huginn: 502 bad gateway

I am having to open yet another ticket for bad gateway. I tried to use the manual install steps on Ubuntu (on an AWS EC2 server): https://github.com/cantino/huginn/blob/master/doc/manual/installation.md

I was receiving 502 bad gateway with the following in nginx log: *4 connect() to unix:/home/huginn/huginn/tmp/sockets/unicorn.socket failed (2: No such file or directory) while connecting to upstream

I changed the Procfile and nginx config to listen to try and create a socket file in another location with the following result: connect() to unix:/var/sockets/unicorn.huginn.socket failed (2: No such file or directory) while connecting to upstream

Then, I changed the Procfile and nginx config to listen to 127.0.0.1:3000 and get this: *1 connect() failed (111: Connection refused) while connecting to upstream

I believe I have unicorn running, but for some reason nginx is not listening on the same socket:

ubuntu@ip-172-31-62-157:/home/huginn/huginn/config$ ps aux | grep unicorn
huginn   21407 46.0  2.1  93944 21880 ?        Rl   11:54   0:02 /home/huginn/huginn/vendor/bundle/ruby/2.3.0/bin/unicorn -c config/unicorn.rb
ubuntu   21417  0.0  0.0  10460   940 pts/0    S+   11:54   0:00 grep --color=auto unicorn

What else do I need to troubleshoot? I am at my wits’ end about this - Any pointers are appreciated!

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Having run into this issue - or something very similar - today myself, I’m documenting my root cause and solution here in case it should be helpful to some other poor soul in the next few years:

Root cause: I wanted to play with my huginn .env variables, so I sensibly made a copy (sudo cpy .env .backup_env) and then when the changes failed, deleted the modified/bad .env and renamed .backup_env to .env, congratulating myself on my foresight.

What I wouldn’t realize til several hours of debugging later (checking /home/huginn/huginn/config/unicorn.rb (or the permissions thereof), checking /etc/nginx//nginx.conf (or the permissions thereof), checking the Procfile, checking the .env file’s actual variables, restarting huginn, rebooting the server, deleting the unicorn.socket and re-running the rake export, etc.), is that little backup maneuver left the .env file owned by root:root instead of by huginn:huginn.

:cue_muffled_screaming:

After changing ownership of .env to huginn:huginn, and re-running: sudo -u huginn -H bundle exec rake assets:precompile RAILS_ENV=production followed by sudo bundle exec rake production:export the 502 error is now gone. Hopefully this helps someone because then I could believe my pain was not totally pointless.

Good luck.