Crudee

Basic HTML CRUD app for SQLite database

Table of Contents

09 Jun 2024

Using Flask (Python) and SQLite, I created a basic HTML CRUD app for a SQLite database. The app allows me to read & update records in a local SQLite database.

Managing port conflicts

My Flask app is supposed to run on port 5000,ie 127.0.0.1:5000 though I have some issues.

1) Conflict with Live Server extension in VS Code = deactivate the extension or ensure it is not running.
2) Conflict with another server process = identify and kill the conflicting process.

To identify conflicting server processes on same port (5000 in this case):

lsof -i :5000

eg.:

❯ lsof -i :5000
COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe   441  nic   10u  IPv4 0x4c4d559212e0967b      0t0  TCP *:commplex-main (LISTEN)
ControlCe   441  nic   11u  IPv6 0x4c4d5596df7b7b2b      0t0  TCP *:commplex-main (LISTEN)
Python    20361  nic    3u  IPv4 0x4c4d559212df7f7b      0t0  TCP localhost:commplex-main (LISTEN)
Python    20828  nic    3u  IPv4 0x4c4d559212df7f7b      0t0  TCP localhost:commplex-main (LISTEN)
Python    20828  nic    4u  IPv4 0x4c4d559212df7f7b      0t0  TCP localhost:commplex-main (LISTEN)

Output Breakdown

1.  COMMAND: The name of the command or process using the port.
2.  PID: The Process ID of the command.
3.  USER: The user who started the process.
4.  FD: File descriptor number.
5.  TYPE: The type of the file (in this case, it is IPv4 or IPv6).
6.  DEVICE: Internal device number.
7.  SIZE/OFF: The size of the file or the offset.
8.  NODE: The inode number.
9.  NAME: The name of the port (in this case, it is commplex-main, which is a mapping for port 5000).

Specific Processes

•   ControlCe: This process has PID 441 and is listening on both IPv4 and IPv6 interfaces.
•   Python: Two Python processes with PIDs 20361 and 20828 are listening on the same port. The process with PID 20828 has multiple entries, which is common when a process has multiple threads or is restarted.

What It Means

   Port 5000 is in Use: The fact that there are multiple entries for port 5000 means that this port is already in use by other processes. This can cause conflicts when you try to run your Flask app on the same port.   ControlCe Process: This might be a system control center or a service that is also using port 5000.   Python Processes: Multiple Python processes are listening on port 5000, which suggests that you might have multiple instances of your Flask app running or other Python applications using the same port.

Solution

To resolve this issue, you need to terminate the processes using port 5000 and then run your Flask app. Here’s how you can do it:

1.  Terminate the Processes: Use the kill command to terminate the processes using port 5000.
kill -9 441 20361 20828

links

social