MishaVacic
MishaVacic

Reputation: 1887

Airflow: Can't connect to ('0.0.0.0', 8080)

I am on Ubuntu 16.04,I have installed Airflow with pip. Next step

airflow initdb
[2017-07-29 12:20:23,483] {__init__.py:57} INFO - Using executor SequentialExecutor
DB: sqlite:////home/milenko/airflow/airflow.db
[2017-07-29 12:20:23,813] {db.py:287} INFO - Creating tables
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.

This works fine.But when I try to start webserver

airflow webserver -p 8080
[2017-07-29 12:20:45,913] [4585] {models.py:167} INFO - Filling up the DagBag from /home/milenko/airflow/dags
Running the Gunicorn Server with:
Workers: 4 sync
Host: 0.0.0.0:8080
Timeout: 120
Logfiles: - -
=================================================================            
[2017-07-29 12:20:46,950] {__init__.py:57} INFO - Using executor SequentialExecutor
[2017-07-29 12:20:47 +0200] [4590] [INFO] Starting gunicorn 19.3.0
[2017-07-29 12:20:47 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080)
[2017-07-29 12:20:47 +0200] [4590] [ERROR] Retrying in 1 second.
[2017-07-29 12:20:48 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080)
[2017-07-29 12:20:48 +0200] [4590] [ERROR] Retrying in 1 second.
[2017-07-29 12:20:49 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080)
[2017-07-29 12:20:49 +0200] [4590] [ERROR] Retrying in 1 second.
[2017-07-29 12:20:50 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080)
[2017-07-29 12:20:50 +0200] [4590] [ERROR] Retrying in 1 second.
[2017-07-29 12:20:51 +0200] [4590] [ERROR] Connection in use: ('0.0.0.0', 8080)
[2017-07-29 12:20:51 +0200] [4590] [ERROR] Retrying in 1 second.
[2017-07-29 12:20:52 +0200] [4590] [ERROR] Can't connect to ('0.0.0.0', 8080)

How to solve this?Is this Gunicorn Server issue or not? With netstat I got this output

sudo netstat -nlp | grep :80
tcp6       0      0 :::8080                 :::*                    LISTEN      1711/java

As I understand the port is in use.But what is 1711/java?If I turn it off will it affect something else? This is the relevant part of my airflow configuration file

[webserver]
# The base url of your website as airflow cannot guess what domain or
# cname you are using. This is used in automated emails that
# airflow sends to point links to the right web server
base_url = http://localhost:8080

# The ip specified when starting the web server
web_server_host = 0.0.0.0

# The port on which to run the web server
web_server_port = 8080

# Paths to the SSL certificate and key for the web server. When both are
# provided SSL will be enabled. This does not change the web server port.
web_server_ssl_cert =
web_server_ssl_key =

# Number of seconds the gunicorn webserver waits before timing out on a worker
web_server_worker_timeout = 120

# Number of workers to refresh at a time. When set to 0, worker refresh is
# disabled. When nonzero, airflow periodically refreshes webserver workers by
# bringing up new ones and killing old ones.
worker_refresh_batch_size = 1

# Number of seconds to wait before refreshing a batch of workers.
worker_refresh_interval = 30

# Secret key used to run your flask app
secret_key = temporary_key

# Number of workers to run the Gunicorn web server
workers = 4

# The worker class gunicorn should use. Choices include
# sync (default), eventlet, gevent
worker_class = sync

Upvotes: 7

Views: 43879

Answers (4)

momo chan
momo chan

Reputation: 1

You can try the following code:

lsof -i :8080

and if nothing appears, it means the 8080 is not in use. If there is something, make sure it's like this

COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
python    1234  admin   3u  IPv4  0x1234567      0t0  TCP *:http-alt (LISTEN)

and make sure you use localhost instead of 0.0.0.0 in the browser

Upvotes: 0

sammy ongaya
sammy ongaya

Reputation: 1401

I had the same issue where the default port 8080 was being used by another process. To resolve this change the port from 8080 to something like 8081.

Go to your airflow directory and open airflow.cfg in an editor. Change all instances of port 8080 to 8081. Save and re-reun the scheduler and webserver now using port 8081.

Upvotes: 4

Ahmad Zareef
Ahmad Zareef

Reputation: 41

The first time you run Airflow, it will create a file called airflow.cfg in your $AIRFLOW_HOME directory (~/airflow by default). This file contains Airflow’s configuration and you can edit it to change any of the settings.

You can find this file and search for web_server_port. Then change it to any unused port. You can then run airflow webserver as usual

Upvotes: 4

Stev
Stev

Reputation: 307

For the sake of completeness: The question was answered elsewhere by Thomas:

Either stop the Java application that uses port 8080 already or change the port for Airflow.

Source

Upvotes: 4

Related Questions