What are the prereqs for the course? Most of the courses I've seen who did not have enough people sign up had lots of prerequisite courses which resulted in many potentially interested students to skip over the course as they weren't eligible.
Assuming there should be a decent chance of plenty of students interested in the course, I'd recommend some of the following methods:
Lots of people from a variety of majors and backgrounds attend club activities for areas of interest. For example- my school has a data-science club which has people from CS, Business, Math, and even some liberal arts majors! If, for example, you were teaching a new data science course in an interesting topic- the club would be your best bet for finding interested students
- Advertising Through Professors
If you know of professors teaching related courses you can pass on the word to them about your course and they can try to inform students they teach about the course. I took a digital forensics course in which the professor recommended we take Networking afterwards cause it covers similar material- and in Networking the professor recommended several times throughout the course we take the security course (and also advertised some of his own courses). This seems like a decent option and definitely worked for me
- Advertising Through other students
Definitely a harder option- but if you have formed any close relationships with students you've taught or met then you can ask them to spread the word of your course or ask if they know of anyone who might be interested. Always worth a shot.
Always need to consider the chance that even though you think the material will be interesting to students- not everyone will feel that same level of interest. Another thing I'd consider is looking at the course description posted online- one of the most interesting grad courses I've taken had the worst descriptions that made it sound utterly boring and it definitely scared most people away from the course.
Good luck! Hope you get to teach the course.