I followed the instructions here https://kifarunix.com/install-and-setup-haproxy-on-ubuntu-20-04/ & have almost set up HTTPS. The function beam.smp which is specific to couchdb was bound to 5984 & hence not allowing haproxy to start.
Error log from terminal:
Oct 04 08:11:58 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:11:58 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:58 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
So I stopped the service to be able to bind the haproxy service to the port. Now beam.smp is not bound to the port but still haproxy is not able to takeover. What could be the reason here?
Oct 04 08:11:58 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:11:58 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:58 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
Oct 04 08:11:59 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Start request repeated too quickly.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
root@AgentDost:~# sudo ss -4 -tlnp | grep 80
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=751,fd=6),("nginx",pid=750,fd=6))
root@AgentDost:~# ss -4 -tlnp | grep 5984
I tried changing the frontend to port 6984 but even that doesn’t help.
Error log from terminal:
Oct 04 08:21:26 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:21:26 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:21:26 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:21:27 AgentDost haproxy[31747]: [ALERT] 276/082126 (31747) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:6984]
Oct 04 08:21:27 AgentDost haproxy[31747]: Proxy webapps started.
Oct 04 08:21:27 AgentDost haproxy[31747]: Proxy webapps started.
Oct 04 08:21:27 AgentDost haproxy[31747]: [ALERT] 276/082126 (31747) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:21:27 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
Oct 04 08:21:27 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Start request repeated too quickly.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:21:27 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
root@AgentDost:~# ss -4 -tlnp | grep 6984
root@AgentDost:~# ss -4 -tlnp | grep 5984
LISTEN 0 128 0.0.0.0:5984 0.0.0.0:* users:(("beam.smp",pid=31658,fd=16))
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Heya,
Based on the provided error logs, it seems that HAProxy is having trouble binding to the specified ports, whether it’s port 5984 or 6984. The error message “cannot bind socket” indicates that something is already using those ports, preventing HAProxy from taking over.
Here are some steps you can take to troubleshoot the issue:
These commands will show you if any processes are bound to those ports. Make sure to stop or reconfigure the processes using these ports to free them up for HAProxy.
Check CouchDB Configuration: Since you mentioned that “beam.smp” is specific to CouchDB and was previously bound to port 5984, ensure that CouchDB is correctly configured and not attempting to bind to the port anymore. Review CouchDB’s configuration files and logs to verify this.
Check HAProxy Configuration: Double-check your HAProxy configuration file to ensure that there are no syntax errors or conflicting configurations. It’s possible that there might be a misconfiguration in the frontend section, causing the issue. Make sure you’ve set the correct backend server(s) and port(s) in the HAProxy configuration.
Restart HAProxy: After verifying and making necessary changes in the configuration, restart the HAProxy service:
This command will display the HAProxy service logs, including any additional error messages or information that might help you identify the problem.
Remember to always back up your configuration files before making changes, so you can easily revert to the previous state if necessary.
By following these steps and investigating the mentioned points, you should be able to identify the cause of the issue and resolve it. If you’re still facing difficulties, feel free to provide more details about your HAProxy and CouchDB configurations, and I’ll be glad to assist further.