Eu uso o Doccano no Ubuntu 22.04.
Recebo o erro "Can't connect to ('0.0.0.0', 80)"
ao pedir ao Doccano para servir na porta 80: qual é o problema?
Pedir ao Doccano para servir na porta 8000 funciona bem.
Mensagem de erro completa:
(doccanopy310) ubuntu@ip-172-30-33-321:~$ doccano webserver --port 80
[2023-08-12 00:16:09 +0000] [36905] [INFO] [django_drf_filepond.apps::ready::61] App init: no django-storages backend configured, using default (local) storage backend if set, otherwise you need to manage file storage independently of this app.
Starting server with port 80.
[2023-08-12 00:16:09 +0000] [36905] [INFO] Starting gunicorn 20.1.0
[2023-08-12 00:16:09 +0000] [36905] [ERROR] Retrying in 1 second.
[2023-08-12 00:16:10 +0000] [36905] [ERROR] Retrying in 1 second.
[2023-08-12 00:16:11 +0000] [36905] [ERROR] Retrying in 1 second.
[2023-08-12 00:16:12 +0000] [36905] [ERROR] Retrying in 1 second.
[2023-08-12 00:16:13 +0000] [36905] [ERROR] Retrying in 1 second.
[2023-08-12 00:16:14 +0000] [36905] [ERROR] Can't connect to ('0.0.0.0', 80)
(doccanopy310) ubuntu@ip-172-30-33-321:~$
Para reproduzir: inicie uma instância do AWS EC2 e execute os seguintes comandos.
Instalei o Doccano com:
# Install conda
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
bash Anaconda3-2023.03-1-Linux-x86_64.sh -b
if ! [[ $PATH =~ "$HOME/anaconda3/bin" ]]; then
PATH="$HOME/anaconda3/bin:$PATH"
fi
conda init bash
source ~/.bashrc
# create conda env and install doccano
conda create -n doccanopy310 python=3.10 anaconda
conda activate doccanopy310
pip install doccano
Para lançar o Doccano, segui a documentação oficial ). eu corri:
# Initialize database. First time only.
doccano init
# Create a super user. First time only.
doccano createuser --username admin --password pass
# Start a web server.
doccano webserver --port 80
E de correu outro terminal:
# Start the task queue to handle file upload/download.
doccano task
Pedir ao Doccano para servir na porta 8000 funciona bem:
(doccanopy310) ubuntu@ip-172-30-33-321:~$ doccano webserver --port 8000
[2023-08-12 00:21:53 +0000] [37206] [INFO] [django_drf_filepond.apps::ready::61] App init: no django-storages backend configured, using default (local) storage backend if set, otherwise you need to manage file storage independently of this app.
Starting server with port 8000.
[2023-08-12 00:21:53 +0000] [37206] [INFO] Starting gunicorn 20.1.0
[2023-08-12 00:21:53 +0000] [37206] [INFO] Listening at: http://0.0.0.0:8000 (37206)
[2023-08-12 00:21:53 +0000] [37206] [INFO] Using worker: sync
[2023-08-12 00:21:53 +0000] [37207] [INFO] Booting worker with pid: 37207
[2023-08-12 00:21:53 +0000] [37208] [INFO] Booting worker with pid: 37208
[2023-08-12 00:21:53 +0000] [37209] [INFO] Booting worker with pid: 37209
[2023-08-12 00:21:54 +0000] [37210] [INFO] Booting worker with pid: 37210
[2023-08-12 00:21:54 +0000] [37211] [INFO] Booting worker with pid: 37211
Não vejo nenhum programa usando a porta 80:
debug to see which ports are being used: From within the machine netstat -ntlp / netstat -nulp will show all open TCP / UDP ports (and associated programs) respectively.
(doccanopy310) ubuntu@ip-172-30-33-321:~$ netstat -nulp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 172.30.33.321:68 0.0.0.0:* -
udp 0 0 127.0.0.1:323 0.0.0.0:* -
udp6 0 0 ::1:323 :::* -
(doccanopy310) ubuntu@ip-172-30-33-321:~$ netstat -ntlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 37206/python
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
(doccanopy310) ubuntu@ip-172-30-33-321:~$
Ambiente:
- Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-1039-aws x86_64)).
Você está executando-o como um usuário normal. Somente root pode ter um processo aberto e escutar em uma porta abaixo de 1024. Você precisará executá-lo como root ou usar uma porta igual ou superior a 1025 e então usar Apache ou Nginx para redirecioná-lo para a porta 80, mas para isso, root terá que criar/editar o(s) arquivo(s) de configuração e reiniciar o daemon.