Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been trying to install CouchDB on my webfusion virtual server. I followed the latest instructions from the webfusion forum (see: http://forum.webfaction.com/viewtopic.php?id=2355 ) and it runs (just) Futon is very sluggish and I get 502 errors. Anyway when I run the test suite it fails on multiple tests. Webfaction support have been great but don't have erlang experience to interpret the error logs. Can anyone help me know what might be wrong?

Test suite result: basics, all_docs, attachments, attachments_multipart, attachment_names, compact, config, conflicts, delayed_commits, design_docs, design_options

all the errors are:

Exception raised: {"error":"unknown","reason":"\u000d\u000a502 Bad Gateway\u000d\u000a\u000d\u000a502 Bad Gateway\u000d\u000a

nginx\u000d\u000a\u000d\u000a\u000d\u000a"}

except for 'compact; which also has:

Assertion failed: xhr.responseText == "This is a base64 encoded text" Assertion failed: xhr.getResponseHeader("Content-Type") == "text/plain"

I'm stumped.

Anybody know what these indicate?

AL

share|improve this question
    
Which browser and OS are you using to run the tests? –  Sam Bisbee Aug 29 '10 at 20:39

1 Answer 1

I've had this problem too. Seems that it's a nginx-CouchDB communication problem. In a middle of a "basics" test, there is a command to restart the CouchDB. After it, nginx log looks like this:

2010/12/02 03:21:09 [error] 708#0: *132 upstream prematurely closed connection while reading response header from upstream, client: 70.205.249.118, server: localhost, request: "POST /_restart HTTP/1.1", upstream: "http://127.0.0.1:5984/_restart", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"
2010/12/02 03:21:10 [error] 708#0: *132 connect() failed (111: Connection refused) while connecting to upstream, client: 70.205.249.118, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5984/", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"
2010/12/02 03:21:10 [error] 708#0: *132 connect() failed (111: Connection refused) while connecting to upstream, client: 70.205.249.118, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5984/", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"

Which means that right after reset CouchDB actively refuses connections and we just need to make another request or two.

The solution was to add something like this in nginx configuration so that it makes 5 requests before presenting error to the user (notice the max_fails part):

upstream  couchdb  {
    server   127.0.0.1:5984       max_fails=5  fail_timeout=30s;
}

server {
    ...
        location / {
            proxy_pass http://couchdb;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

Hope this helps.

Update: after a little testing, this method didn't help either. nginx makes requests too fast. Maybe someone has enough knowledge to elaborate?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.