[Openstack Swift] Could not bind to 0.0.0.0:8080

Updated on September 29, 2021

I have successfully installed and configured the OpenStack Swift service. However, I see an ‘Account not found’ error while executing swift stat command.  Digging the log file revealed this error – OpenStack Swift Could not bind to 0.0.0.0:8080 after trying for 30 seconds. Below are the complete error messages.

[root@controller swift(swift)]# swift stat
Account not found

And also /var/log/messages provided the below errors:

Sep 28 11:31:34 controller swift-proxy-server: Traceback (most recent call last):
Sep 28 11:31:34 controller swift-proxy-server: File "/usr/bin/swift-proxy-server", line 23, in <module>
Sep 28 11:31:34 controller swift-proxy-server: sys.exit(run_wsgi(conf_file, 'proxy-server', **options))
Sep 28 11:31:34 controller swift-proxy-server: File "/usr/lib/python2.7/site-packages/swift/common/wsgi.py", line 1115, in run_wsgi
Sep 28 11:31:34 controller swift-proxy-server: error_msg = strategy.do_bind_ports()
Sep 28 11:31:34 controller swift-proxy-server: File "/usr/lib/python2.7/site-packages/swift/common/wsgi.py", line 694, in do_bind_ports
Sep 28 11:31:34 controller swift-proxy-server: self.sock = get_socket(self.conf)
Sep 28 11:31:34 controller swift-proxy-server: File "/usr/lib/python2.7/site-packages/swift/common/wsgi.py", line 195, in get_socket
Sep 28 11:31:34 controller swift-proxy-server: 'timeout': bind_timeout})
Sep 28 11:31:34 controller swift-proxy-server: Exception: Could not bind to 0.0.0.0:8080 after trying for 30 seconds

Well, here’s the solution.

Fix OpenStack Swift could not bind to 0.0.0.0:8080

Looking at the error, it is clear that port 8080 is not available for the service to start.

How to find which service has used port 8080?

Now we need to find which service has used port 8080 using netstat command as below:

[root@controller ~(swift)]# netstat -lntp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 8759/java

From the above, it is clear that a JAVA application is using port 8080 already!

Let’s find which JAVA application by grepping the process id 8759

[root@controller ~(swift)]# ps -ef|grep 8759
root 8759 1 0 Aug21 ? 01:27:05 /usr/local/jdk1.7.0_51/bin/java -Djava.util.logging.config.file=/root/WebApplication/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/root/WebApplication/endorsed -classpath /root/WebApplication/bin/bootstrap.jar:/root/WebApplication/bin/tomcat-juli.jar -Dcatalina.base=/root/WebApplication -Dcatalina.home=/root/WebApplication -Djava.io.tmpdir=/root/WebApplication/temp org.apache.catalina.startup.Bootstrap start
root 12103 5399 0 16:25 pts/5 00:00:00 grep --color=auto 8759

Now it is clear that the tomcat application has already been bound to port 8080 because of which swift service couldn’t start on port 8080.

How to run OpenStack Swift on port 8081?

Since already an application is running on port 8080, we shall start the OpenStack Swift service on port 8081. Open the file /etc/swift/proxy-server.conf file and change the bind_port to 8081 as below:

[root@controller ~(swift)]# vim /etc/swift/proxy-server.conf

[DEFAULT]
bind_port = 8081
workers = 8
user = swift
auth_strategy=keystone

To access the service URLs, create the endpoint on port 8081 as below:

[root@controller ~(swift)]# openstack endpoint create --region RegionOne object-store public http://$swift_proxy:8081/v1/AUTH_%\(tenant_id\)s

[root@controller ~(swift)]# openstack endpoint create --region RegionOne object-store internal http://$swift_proxy:8081/v1/AUTH_%\(tenant_id\)s

[root@controller ~(swift)]# openstack endpoint create --region RegionOne object-store admin http://$swift_proxy:8081/v1

Restart the Openstack-swift-proxy service

[root@controller ~(swift)]# systemctl restart openstack-swift-proxy.service

Now the command swift stat works charmingly!

[root@controller ~(swift)]# swift stat
Account: AUTH_2c5e8dd6bc9e420bb0880435f5c8c1ba
Containers: 2
Objects: 4
Bytes: 1706507
Containers in policy "policy-0": 2
Objects in policy "policy-0": 4
Bytes in policy "policy-0": 1706507
X-Account-Project-Domain-Id: default
X-Openstack-Request-Id: tx88e3ae617ee2451a94973-006152f67f
X-Timestamp: 1632813563.95384
X-Trans-Id: tx88e3ae617ee2451a94973-006152f67f
Content-Type: application/json; charset=utf-8
Accept-Ranges: bytes

Was this article helpful?

Related Articles

Leave a Comment