Monthly Archives: May 2013

Nginx: upstream timed out (110: Connection timed out)

Error 110: Connection timed out while reading response header from upstream

Sometimes a Nginx web server seems to load pages with php code with a lot of xml parsing really slowly. Often it doesn’t load or connection times out. This will be seen more on pages where the php code parses through large xml files and outputs data only when all the parsing is complete. The Nginx web server times out before php returns output.

We have to make the Nginx web server wait more before giving up on the upstream.

This is a typical error I get:

upstream timed out (110: Connection timed out) while reading response header from upstream

or

connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream

and such. The second one is inexplicable, since everything is working when not timing out, but I have often seen these two together.

The fix that works is increasing the timeout.

In the server configuration /etc/nginx/nginx.conf on Ubuntu/Debian, in the http {....} block, add the line (or edit the commented out line)
fastcgi_read_timeout 300s;

Restart the Nginx web server (as root or with sudo).
service nginx restart

There should be an immediate improvement when parsing large xml files. If you are still having problems, raise the number till resolved.

English: Nginx Logo Español: Logo de Nginx

English: Nginx web server Logo Español: Logo de Nginx (Photo credit: Wikipedia)

Enhanced by Zemanta

Fix a broken mysql

If your mysql seems broken and giving errors like:

# service mysql start
start: Job failed to start

or

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Or if you try to recreate databases with mysqlinstalldb:

...
...
ERROR: 1  Can't create/write to file './mysql/db.frm' (Errcode: 13)
041226 xx:xx:xx /usr/libexec/mysqld: Can't find file: './mysql/db.frm' (errno: 13)

or all your databases go missing, even if you reinstall mysql-server.

and reinstalling mysql-server won’t work,

Before you reformat the server and use your data, you should try doing (as root, or using sudo):

apt-get install --reinstall mysql-server

chown -R mysql:mysql /var/lib/mysql

I don’t know how, but somehow the permissions get changed and mysql can no longer operate, or a reinstalled mysql still can’t see the tables. They are not gone, they are there. mysql can’t see them and that can be fixed.

Note: Some complained that if they do:

apt-get install mysql or apt-get remove mysql

They get the error that the package can’t be found. Something like:

# apt-get remove mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mysql

That has nothing to do with this. This happens because the package for mysql in the repositories is mysql-server and not mysql alone. Doing apt-get install mysql-server will work.

How to retrieve your passwords saved in Google Chrome or Chromium on ubuntu linux

If you are like me, you have loads of passwords saved in the Chrome browser. And then you need them. Maybe you want to stop using Chrome, or you want them to enter into some applcation other than the browser… or perhaps you just want a list of all sites you have passwords for – curiosity… whatever the reason, it isn’t easy to discover how to do this.

This solution is based on one I found at The Big Browser with two very minor changes where that code didn’t work for me.

Before beginning, make sure you are signed in from your Google Chrome or Chromium browser and your passwords are synced and available.

Close the browser.

Next, open the browser from the command line, with a temporary profile that stores passwords without encryption. Like so (pick one of the lines depending on the browser you are using)

### Google Chrome
    google-chrome --user-data-dir=/tmp/chrome-tmp --password-store=basic

### Chromium
    chromium --user-data-dir=/tmp/chrome-tmp --password-store=basic

This did not work for me – I use Chromium. I had to use this:

### Chromium
    chromium-browser --user-data-dir=/tmp/chrome-tmp --password-store=basic

I have no idea what happens with Google Chrome, but if the given line doesn’t work, appending -browser to google-chrome is worth a try.

This will open a separate session. Sign in to the browser with your account and wait for a while till your passwords are synchronized. You can surf if you want. When your data is syncronized, your saved websites and bookmarks will be available. You can go to “Manage passwords” in settings and see that your passwords are loaded. If you don’t see them, wait some more time till you do.

Close the browser.

Note: the fastest way to get to the stored passwords page in settings is to type password in the Search box in the top right.

In the terminal, enter:

cd /tmp/chrome-tmp/Default

For the next step, you will need sqlite3 installed. If it isn’t installed, you can install it by entering:

sudo apt-get install sqlite3

Then enter:

sqlite3 'Login Data'

At the changed prompt, now enter the following lines one by one.

.mode csv               # other options are `html', `tabs', etc.
.headers on
.separator ","
.output chrome_passwords.csv
select * from logins;
.exit

This will give you a file called chrome_passwords.csv with your Chrome passwords.

To open it with LibreOffice, type:

libreoffice --calc chrome_passwords.csv

The passwords will open as a spreadsheet. You also will be able to import this spreadsheet into other keyword managers if you need to.