Category Archives: Troubleshooting

OpenVZ and UFW

So I found another problem area with the OpenVZ host and the Ubuntu Server. A good firewall is important for the safety of a server, but I, at least feel overwhelmed at the complexity and risk of messing things up very badly to directly touch iptables, and I have only done on rare occasions, and always worried.

UFW is a great and simple firewall application. Unfortunately if your server is on OpenVZ, you will not be able to use it out of the box because of the limited support for iptables. Here is a superb workaround in order to be able to use UFW on a Ubuntu host on OpenVZ. The instructions work well.

Will take you a while to do it all, but works like a charm, and the code is copy paste.

If, at the end of it, your installation of dependencies fails, and any further attempts to access repositories don’t work, DON’T PANIC. Simply disable and enable UFW and all should be well.

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

So you ran an upgrade, or got carried away tweaking things on your server, and now MySQL is acting like an island of its own. Your websites can’t connect, your phpmyadmin can’t connect, and you are miserable.

You get errors like

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

and, you being a n00b like me, are at your wits end.

I may have a quick fix as long as the error is 2002 and it is complaining about a socket.

Go to your MySQL configuration file [which on Ubuntu is /etc/mysql/my.cnf ]

There, copy the socket mysqld is using. It will be something like


Copy the line that says socket=/whatever/address/to/the/file.sock

See if there is a block for [client] that mentions socket. If there isn’t, make one below the block for [mysqld] and paste your socket line. If there is, fix the location to match.

Try now. No restart or anything needed. If it will work, it will work right away. If you have done good things in your life and deserve a break, this should put you out of your misery. 😀 It is among the likeliest culprits if new files and upgrades and such have happened.

If this doesn’t happen, then I would investigate to see if that location exists, has right permissions and such things…. or someone mentioned other checking for other configurations that may be messing with this – which I can’t even imagine where to begin.

Good Luck!

Problems upgrading your Ubuntu Server to 12.04 Ubuntu Precise Pangolin?

If you are running a Ubuntu server on a VPS, the latest upgrade may have brought dismay with warnings and errors and finally failure. Some of the sample output can look like:

Processing triggers for man-db …
locale: /lib/x86_64-linux-gnu/ version `GLIBC_2.15′ not found (required by locale)
locale: /lib/x86_64-linux-gnu/ version `GLIBC_2.14′ not found (required by locale)

A fatal error occurred

Please report this as a bug and include the files
/var/log/dist-upgrade/main.log and /var/log/dist-upgrade/apt.log in
your report. The upgrade has aborted.
Your original sources.list was saved in

SystemError: E:Sub-process /usr/bin/dpkg returned an error code (1)
ERROR:root:SystemError from cache.commit(): installArchives() failed

Could not install the upgrades

The upgrade has aborted. Your system could be in an unusable state. A
recovery will run now (dpkg –configure -a).

Please report this bug in a browser at and
attach the files in /var/log/dist-upgrade/ to the bug report.
installArchives() failed

Setting up libsnmp-base (5.4.3~dfsg-2.4ubuntu1.1) …
dpkg: dependency problems prevent configuration of libnih-dbus1:
libnih-dbus1 depends on libnih1 (= 1.0.3-4ubuntu9); however:
Version of libnih1 on system is 1.0.3-4ubuntu2.
dpkg: error processing libnih-dbus1 (–configure):
dependency problems – leaving unconfigured
Errors were encountered while processing:

Upgrade complete

The upgrade has completed but there were errors during the upgrade

dpkg: error processing libnih-dbus1 (–configure):

dependency problems – leaving unconfigured
Errors were encountered while processing:

and so on.

The main reason for this is that your host is running a kernel that is no longer supported, so the upgrade kind of… refuses. To be sure that this is the problem, run:

uname -r

if you get 2.6.18 then this post is likely to help you. The problem apparently occurs because “your host is almost certainly running OpenVZ on a 2.6.18 kernel (all OpenVZ containers share the host kernel)” according to Ishaan Dalal. “The problem is that the libc 2.15 included with Precise requires a minimum 2.6.24 kernel to function.” He is maintaining a repository with a workaround for this.

To use the repository, add it to your sources the easy way like this:

apt-add-repository ppa:izx/ovz-libc

Chances are that this may not work for the same reason the upgrade didn’t – because stuff is broken, in which case, you add the following lines to /etc/apt/sources.list

deb precise main
deb-src precise main

And run:

sudo apt-key adv –keyserver –recv-keys BFAB4BD9

After which if you run

apt-get update

apt-get install -f

apt-get dist-upgrade

you are likely to go smoothly into the upgrade. Follow prompts, etc. Reboot when done, and you should be fine.

…. or at least I was.

Configuring Privoxy to use TOR

In these days of censorship concerns, increasing numbers of people are using TOR as a proxy and thus, increasing numbers of people are configuring their browsers wrong and going to the TOR check page only to realize that for all their proxy configurations, they either cannot see the page at all, or they see the result that they are not using TOR.

You set your HTTP Proxy to 8118, Socks5 Proxy to 9050 and imagined that it would work, but it doesn’t. Here’s what could be going wrong.

The proxy server is refusing connections


Firefox is configured to use a proxy server that is refusing connections.

This means that while you installed TOR, you did not install Privoxy. The port 8118 points to the Privoxy proxy. If you haven’t installed it, there is nothing to receive the connections. On Ubuntu, go

sudo apt-get install privoxy

On Windows… go to to download a suitable release. Install.

Which brings you to the next problem.

Sorry. You are not using TOR

You have checked everything. TOR is running. The onion is green. You have installed privoxy. It is running. Your proxy setting is 8118. You are able to access sites. BUT YOU ARE NOT USING TOR.

This is because privoxy is a proxy that:

Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk.

It does NOT use TOR unless you tell it to. You can do this by manually editing the configuration file, which on Ubuntu is located at /etc/privoxy/config (will update with the windows location soon, but should be easily found in the program files for privoxy.

Open it as root. Do a ‘find text’ for “localhost:9050”. The line will say:

# forward-socks5 / localhost:9050 .

Uncomment it by deleting the “#” in the beginning. Save and close file.

Now point your browser to

You should see a bold green heading:

Congratulations. Your browser is configured to use TOR.


Note: If you do not see this text, please troubleshoot further. Without this text, your browsing is NOT anonymous.

WordPress Database Error: You have an error in your SQL syntax

When I used a slideshow plugin on AamJanata, I got this error.

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'orderorder` INT(11) NOT NULL DEFAULT '0'' at line 1]
ALTER TABLE wp_gallery_slides CHANGE COLUMN order order INT(11) NOT NULL DEFAULT '0'`

Lot of investigation and frustration later led me to realize that if something is working for everyone and not for you, it is useful to look at your unique set up rather than the code.

Snooping in my databases showed me that the Character set used for the table for that plugin was not utf8, – actually different ones for two different plugins both giving me errors. Setting it right fixed the problem.

What to do?
Go to your database in PhpMyAdmin. Run your eyes down the encoding column and see which tables if any have encoding other than what the rest of the database is using. Chances are high that that will be the one giving you trouble. Go to the Operations tab for that table, set the encoding to what the rest of the database is using.