Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

johndoee's avatar

why nginx not listen to defined port number

i try to run laravel websocket app by nginx on EC2 instance. when hosting laravel project to EC2, for HTTP port listening, I add inbound rule port 80 for HTTP. So port 80 already used. So I set nginx listen port to 8080 . i also add security inbound rule port number 8080 for this nginx configuration .

after that i successfully run

sudo nginx -t

configuration is ok

but i cannot start nginx,show error.

i checked its error log. show error is it try to connect to port 80

what wrong this. i set port number 8080 in configuration of nginx. why nginx try to connect port 80

0 likes
1 reply
lbecket's avatar

There could be multiple reasons for this:

Incorrect Nginx Configuration: The nginx configuration file should have the correct port number defined, and it should match the port number specified in the inbound security rule in your EC2 instance. If the configuration file is incorrect, nginx will not be able to bind to the specified port number.

Firewall Restrictions: Make sure that the firewall on the EC2 instance is not blocking the incoming traffic to port 8080. Check the firewall rules and add an exception for port 8080 if necessary.

Port Conflict: It's possible that another service or process is using port 8080 and preventing nginx from binding to it. You can use the lsof command to check which process is using the port, and either stop the process or change its port number to resolve the conflict.

If none of these solutions works, try checking the error log of nginx to get more information on the issue and resolve it.

Please or to participate in this conversation.