My First Postmortem: Let’s Start

Maroua alaya
3 min readOct 3, 2021

--

Debugging usually takes a big chunk of a software engineer’s time. The art of debugging is tough and it takes years, even decades to master, and that is why seasoned software engineers are the best at it… experience

Coding is the process of identifying and solving problems. In my blog, we will try to give you the steps to avoid and solve problems in your code. Thank you for reading and happy coding! So, let’s get started!!

First, error messages and warnings are provided for your benefit. If you get an error or warning message, take a moment to read through it. Many simple, but unapparent, problems will be made clear, and you will now have a point from which to start your search for a solution to more complex problems.

Just you need to:

  • Think about the steps real world analogies for the problem.
  • Clearly define all your inputs and outputs.

I will try to make the issue more clear buy using one of the web stack debugging project issue I have personally face.

My problem begin when I used the command curl from listening on port 80:

root@966c5664b21f:/# curl 0:80
curl: (7) Failed to connect to 0 port 80: Connection refused

Honestly, at the begging it seems hard for me to know the error, so I’ve tried to start and destroy as many containers as I need to debug the issue. After that, I could suggest starting with the following steps on how to troubleshoot common Nginx problems on a Linux server. I think that I need to handle the default configuration of Nginx.

root@c417ecdf1bf0:/# cd etc/nginx/
root@c417ecdf1bf0:/etc/nginx# ls
conf.d koi-utf mime.types naxsi.rules nginx.conf scgi_params sites-enabled win-utf
fastcgi_params koi-win naxsi-ui.conf.1.4.1 naxsi_core.rules proxy_params sites-available uwsgi_params

The sites-available folder is for storing all of your host configurations, whether or not they're currently enabled.

The sites-enabled folder contains symlinks to files in the sites-available folder. This allows you to selectively disable vhosts by removing the symlink.

root@c417ecdf1bf0:/etc/nginx# cd sites-available/root@c417ecdf1bf0:/etc/nginx/sites-available# ls
default
root@c417ecdf1bf0:/etc/nginx/sites-available#
root@c417ecdf1bf0:/etc/nginx# cd sites-enabled/
root@c417ecdf1bf0:/etc/nginx/sites-enabled# ls
default

So, after spending three hours searching for the error I discover that the file default in the folder sites-enabled is not the same file in the folder sites-available. This is the problem that made the error. So, I fixed the error by removing the file default in the folder sites-enabled, then I create a symbolic link in Unix using this command ln -s source_file myfile

I’ve written a bash script with the minimum number of commands to automate my fix:

#!/usr/bin/env bash
# Configures an Nginx server to listen on port 80.
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
sudo service nginx restart

After running this commands, I succeed to fix the error:

Finally, I think that it can be so important to fix some error by yourself, just the idea is to ask a set of questions until you find the issue.

Thanks for reading!

Maroua Alaya.

--

--

No responses yet