Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into issue port already in use #1

Open
dzincone opened this issue Aug 24, 2017 · 13 comments
Open

Running into issue port already in use #1

dzincone opened this issue Aug 24, 2017 · 13 comments

Comments

@dzincone
Copy link

INFO: Docker container 1f741df9d2b7 is running aws_beanstalk/current-app.
ERROR: [Instance: i-0cccb2bac7313d483] Command failed on instance. Return code: 1 Output: (TRUNCATED)...[emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED].

This happens from editing the file and running the bash script for redirects. Any idea on how to fix that?

@JungleCatSW
Copy link
Owner

When does this happen ? from a fresh startup ? Can you find out what is running on that port ?

@Gary-Pan
Copy link

Gary-Pan commented Oct 26, 2017

I have the same issue from a fresh startup.

Application deployment failed at 2017-10-26T05:58:56Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh failed.

Stopping nginx: [ OK ]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED].

Then I check the 80 port on that instance as follow.
$ sudo lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 4573 root 6u IPv4 15742 0t0 TCP *:http (LISTEN)
nginx 4576 nginx 6u IPv4 15742 0t0 TCP *:http (LISTEN)

@JungleCatSW
Copy link
Owner

Seems like nginx was already running ? are you using the setup below ?
64bit Amazon Linux 2016.09 v2.5.2 running Docker 1.12.6

@Gary-Pan
Copy link

Yes, nginx was already running.
I used the default platform 64bit Amazon Linux 2017.03 v2.7.4 running Docker 17.03.2-ce

@hfmw
Copy link

hfmw commented Mar 24, 2018

Hi @Gary-Pan @JungleCatSW @dzincone ,
I'm getting this too. How did you fix it?
Cheers!
Will

@hfmw
Copy link

hfmw commented Mar 25, 2018

For anyone reading this there is an issue with nginx-setup-config. It works when you first deploy, but if you modify setup or redeploy it gives errors. I think this is due to the folder move commands at the bottom of the file.

@JungleCatSW
Copy link
Owner

Hi @willmoss1000 the script is designed for blue-green deployment. You shouldn't reuse an EB instance, instead start a new one with your modifications and then transfer the the urls once the new EB is ready. Then terminate the original EB. Use the menu option highlighted in red below to swap urls:
blue-green

This way your site has no downtime!

Look up 'Blue Green' Deployment to find out more.

@hfmw
Copy link

hfmw commented Mar 25, 2018

Ah I see, thanks @JungleCatSW!

Sorry... just one more question. I'm getting the following error: Error during WebSocket handshake: Unexpected response code: 400. This must be something to do with the nginx config? Why might this be?

Thanks!!

@JungleCatSW
Copy link
Owner

@willmoss1000 Hi if you are still getting this can you start another issue on here and paste in the full error and where the error log came from. Cheers!

@hfmw
Copy link

hfmw commented Mar 27, 2018

Thanks @JungleCatSW! So like the others I'm running into this error:

/var/log/nginx/error.log
2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/03/27 11:59:13 [emerg] 4828#0: still could not bind()
2018/03/27 11:59:19 [error] 4817#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: XXXXX, server: www.XXXXXXX, request: "GET / HTTP/1.1", upstream

Even if I fix it with sudo fuser -k 80/tcp I get an error saying that proxy isn't working.

I'm pretty sure I've followed your steps exactly. What do can I do to prevent this error on startup?

Cheers!

@JungleCatSW
Copy link
Owner

@willmoss1000 ill take a look and get back to you

@JungleCatSW
Copy link
Owner

@willmoss1000 the 400 error is different to the port in use error though right ?
The port in use error is just because scripts shouldnt be reused.
A 400 error is a bad request, so it could be to do with the domain information you are adding ? such as -- server_name in nginx
-- 301 redirects nginx
-- or possibly eve route 53 to ELB mapping

Do you know how to get the full logs from ELB ?

@hfmw
Copy link

hfmw commented Apr 4, 2018

@JungleCatSW Sorry for the delay in going back. I'm using a classic load balancer as this script doesn't work currently. Yep, tried on a fresh install and kept getting 2018/03/27 11:59:13 [emerg] 4828#0: bind() to 0.0.0.0:80 failed (98: Address already in use).

Does it work for you?? Would be great if I could get it working as an application load balancer! Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants