My website is running on AWS EC2 on /var/www/html on port 5000. I would like to create a DNS A Zone test.example.com linked to that website. On the domain page I can only add the IP, not the port, so test.example.com:5000 works, but test.example.com doesn't. How can I do it?

This is my VirtualDirectory:

<VirtualHost *:5000>
ServerName test.example.com
DocumentRoot /var/www/html
  • 423
  • 3
  • 6
  • 20

2 Answers2


This is a duplicate of the following question. With the use of modproxy this is pretty straightforward. How do I redirect subdomains to a different port on the same server?

  • 118
  • 1
  • 8

DNS only resolves IPs, not port numbers.

One option that would work would be to create a virtual host on port 80 or 443 that forwards you to port 5000. AWS Elastic Load balancer could do something similar (listen on port 80 on the frontend, but send requests to port 5000 on the backend.

Jim G.
  • 2,657
  • 1
  • 19
  • 19