質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

解決済

1回答

3918閲覧

vagrant port8000は使用中というエラーが

roronoazoro

総合スコア113

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

0クリップ

投稿2017/08/15 01:26

編集2017/08/15 12:58

下記サイトを参考に進めております。
現在Ansibleの学習を進めており、環境構築の導入の部分でつまづいています。
長文でもうしわけないでエラー内容とVagrantfileを記載いたします。
質問としては、下記Vagrantfileの内容でupするとport8000は使用中といったエラーを返されてしまいます。
一応VirtualBoxを立ち上げて他に立ち上がっているのがないか確認もしました。
この場合のport8000エラーはどうすればいいでしょうか?

随時試したことは追記していくつもりです。
よろしくお願いします。

bash

1$ vagrant up 2 3#エラー内容 4Vagrant cannot forward the specified ports on this VM, since they 5would collide with some other application that is already listening 6on these ports. The forwarded port to 8000 is already in use 7on the host machine. 8 9To fix this, modify your current project's Vagrantfile to use another 10port. Example, where '1234' would be replaced by a unique host port: 11 12 config.vm.network :forwarded_port, guest: 80, host: 1234 13 14Sometimes, Vagrant will attempt to auto-correct this for you. In this 15case, Vagrant was unable to. This is usually because the guest machine 16is in a state which doesn't allow modifying port forwarding. You could 17try 'vagrant reload' (equivalent of running a halt followed by an up) 18so vagrant can attempt to auto-correct this upon booting. Be warned 19that any unsaved work might be lost. 20~/Google ドライブ/FELICA/Owlcamp/Ansible/

Vagrantfile

bash

1# -*- mode: ruby -*- 2# vi: set ft=ruby : 3 4# All Vagrant configuration is done below. The "2" in Vagrant.configure 5# configures the configuration version (we support older styles for 6# backwards compatibility). Please don't change it unless you know what 7# you're doing. 8Vagrant.configure("2") do |config| 9 10 config.vm.define :node1 do |node| 11 node.vm.box = "bento/centos-7.3" 12 node.vm.network :forwarded_port, guest: 22, host: 2001, id: "ssh" 13 node.vm.network :private_network, ip: "192.168.33.11" 14 end 15 16 config.vm.define :node2 do |node| 17 node.vm.box = "bento/centos-7.3" 18 node.vm.network :forwarded_port, guest: 22, host: 2002, id: "ssh" 19 node.vm.network :forwarded_port, guest: 80, host: 8000, id: "http" 20 node.vm.network :private_network, ip: "192.168.33.12" 21 end 22 # The most common configuration options are documented and commented below. 23 # For a complete reference, please see the online documentation at 24 # https://docs.vagrantup.com. 25 26 # Every Vagrant development environment requires a box. You can search for 27 # boxes at https://vagrantcloud.com/search. 28 config.vm.box = "bento/centos-7.3" 29 30 # Disable automatic box update checking. If you disable this, then 31 # boxes will only be checked for updates when the user runs 32 # `vagrant box outdated`. This is not recommended. 33 # config.vm.box_check_update = false 34 35 # Create a forwarded port mapping which allows access to a specific port 36 # within the machine from a port on the host machine. In the example below, 37 # accessing "localhost:8080" will access port 80 on the guest machine. 38 # NOTE: This will enable public access to the opened port 39 # config.vm.network "forwarded_port", guest: 80, host: 8080 40 41 # Create a forwarded port mapping which allows access to a specific port 42 # within the machine from a port on the host machine and only allow access 43 # via 127.0.0.1 to disable public access 44 # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" 45 46 # Create a private network, which allows host-only access to the machine 47 # using a specific IP. 48 config.vm.network "private_network", ip: "192.168.33.10" 49 50 # Create a public network, which generally matched to bridged network. 51 # Bridged networks make the machine appear as another physical device on 52 # your network. 53 # config.vm.network "public_network" 54 55 # Share an additional folder to the guest VM. The first argument is 56 # the path on the host to the actual folder. The second argument is 57 # the path on the guest to mount the folder. And the optional third 58 # argument is a set of non-required options. 59 # config.vm.synced_folder "../data", "/vagrant_data" 60 61 # Provider-specific configuration so you can fine-tune various 62 # backing providers for Vagrant. These expose provider-specific options. 63 # Example for VirtualBox: 64 # 65 # config.vm.provider "virtualbox" do |vb| 66 # # Display the VirtualBox GUI when booting the machine 67 # vb.gui = true 68 # 69 # # Customize the amount of memory on the VM: 70 # vb.memory = "1024" 71 # end 72 # 73 # View the documentation for the provider you are using for more 74 # information on available options. 75 76 # Enable provisioning with a shell script. Additional provisioners such as 77 # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 78 # documentation for more information about their specific syntax and use. 79 # config.vm.provision "shell", inline: <<-SHELL 80 # apt-get update 81 # apt-get install -y apache2 82 # SHELL 83end 84

Ansible Tutorial

8/15追記

bash

1$ sudo netstat -an | grep LISTEN 2 3tcp4 0 0 *.2001 *.* LISTEN 4tcp46 0 0 *.1110 *.* LISTEN 5tcp4 0 0 *.1110 *.* LISTEN 6tcp4 0 0 127.0.0.1.9999 *.* LISTEN 7tcp4 0 0 127.0.0.1.17603 *.* LISTEN 8tcp4 0 0 127.0.0.1.17600 *.* LISTEN 9tcp4 0 0 *.17500 *.* LISTEN 10tcp6 0 0 *.17500 *.* LISTEN 11tcp4 0 0 127.0.0.1.15292 *.* LISTEN 12 13$ ps -ef | grep vagrant 14501 42324 41619 0 9:55PM ttys000 0:00.00 grep vagrant

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

sh

1sudo netstat -an | grep LISTEN

すると8000番ポートが何かに使われているのが分かると思います。

8000ポートを使っているプロセスが特定できなければ、
エラーメッセージにあるように1234ポート(上記のLISTENしているポート以外の番号)を空けてみてください。

To fix this, modify your current project's Vagrantfile to use another port. Example, where '1234' would be replaced by a unique host port: config.vm.network :forwarded_port, guest: 80, host: 1234

投稿2017/08/15 05:08

zooiiooz

総合スコア176

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

roronoazoro

2017/08/15 11:58

ご回答ありがとうございます。本文下にsudo netstat -an | grep LISTEN の実行結果を追記しました。8000は使われていないかと思われます。 質問なのですが、自分がVagrantfileに記載しているポートでは、node2の80部分のみかぶっているだけのように思えるのですが、1234はスルーして大丈夫でしょうか? またポートは任意の数字で大丈夫なのでしょうか? すみませんがよろしくお願いします。
roronoazoro

2017/08/15 12:57

ありがとうございます。 一応、VM VirtualBoxマネージャーで電源オフというのは確認しているのですが。。 ご指示いただきました結果が下記のようになりました。 501 42324 41619 0 9:55PM ttys000 0:00.00 grep vagrant
zooiiooz

2017/08/15 13:20

すみません config.vm.network :forwarded_port, guest: 80, host: 1234 ではなく node.vm.network :forwarded_port, guest: 80, host: 8000, id: "http" を node.vm.network :forwarded_port, guest: 80, host: 1234, id: "http" にするとどうなりますか? ポート番号ですが、forwardedしているだけなので[1024~65535]の範囲であれば。 8000とか8080はよく使われることがあります。
roronoazoro

2017/08/15 13:38

ありがとうございます。 ご指示いただいた通り操作したところvagrant up成功しました。 ポートの部分など認識が甘いのでこれから勉強指定いきたいと思います。 遅くまでありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問